Skip to content

Commit cbec4b5

Browse files
committed
Minor improvements in video attachments
1 parent 7ed870c commit cbec4b5

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

Web/Models/VideoDrivers/VideoDriver.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ abstract function getThumbnailURL(): string;
1414

1515
abstract function getURL(): string;
1616

17-
abstract function getEmbed(): string;
17+
abstract function getEmbed(string $w = "600", string $h = "340"): string;
1818
}

Web/Models/VideoDrivers/YouTubeVideoDriver.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ function getURL(): string
1313
return "https://youtu.be/$this->id";
1414
}
1515

16-
function getEmbed(): string
16+
function getEmbed(string $w = "600", string $h = "340"): string
1717
{
1818
return <<<CODE
1919
<iframe
20-
width="600"
21-
height="340"
20+
width="$w"
21+
height="$h"
2222
src="https://www.youtube-nocookie.com/embed/$this->id"
2323
frameborder="0"
2424
sandbox="allow-same-origin allow-scripts allow-popups"

Web/Presenters/templates/components/attachment.xml

+13-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@
99
</a>
1010
{/if}
1111
{elseif $attachment instanceof \openvk\Web\Models\Entities\Video}
12-
<div class="bsdn media" data-name="{$attachment->getName()}" data-author="{$attachment->getOwner()->getCanonicalName()}">
13-
<video class="media" src="{$attachment->getURL()}"></video>
14-
</div>
12+
{if $attachment->getType() === 0}
13+
<div class="bsdn media" data-name="{$attachment->getName()}" data-author="{$attachment->getOwner()->getCanonicalName()}">
14+
<video class="media" src="{$attachment->getURL()}"></video>
15+
</div>
16+
{else}
17+
{var $driver = $attachment->getVideoDriver()}
18+
{if !$driver}
19+
<span style="color:red;">{_version_incompatibility}</span>
20+
{else}
21+
{$driver->getEmbed("100%")|noescape}
22+
{/if}
23+
{/if}
24+
1525
<div class="video-wowzer">
1626
<img src="/assets/packages/static/openvk/img/videoico.png" />
1727
<a href="/video{$attachment->getPrettyId()}">{$attachment->getName()}</a>

0 commit comments

Comments
 (0)