Minor improvements in video attachments

This commit is contained in:
celestora 2023-02-07 22:39:07 +02:00
parent 7ed870c3c6
commit cbec4b549f
3 changed files with 17 additions and 7 deletions

View file

@ -14,5 +14,5 @@ abstract class VideoDriver
abstract function getURL(): string;
abstract function getEmbed(): string;
abstract function getEmbed(string $w = "600", string $h = "340"): string;
}

View file

@ -13,12 +13,12 @@ final class YouTubeVideoDriver extends VideoDriver
return "https://youtu.be/$this->id";
}
function getEmbed(): string
function getEmbed(string $w = "600", string $h = "340"): string
{
return <<<CODE
<iframe
width="600"
height="340"
width="$w"
height="$h"
src="https://www.youtube-nocookie.com/embed/$this->id"
frameborder="0"
sandbox="allow-same-origin allow-scripts allow-popups"

View file

@ -9,9 +9,19 @@
</a>
{/if}
{elseif $attachment instanceof \openvk\Web\Models\Entities\Video}
{if $attachment->getType() === 0}
<div class="bsdn media" data-name="{$attachment->getName()}" data-author="{$attachment->getOwner()->getCanonicalName()}">
<video class="media" src="{$attachment->getURL()}"></video>
</div>
{else}
{var $driver = $attachment->getVideoDriver()}
{if !$driver}
<span style="color:red;">{_version_incompatibility}</span>
{else}
{$driver->getEmbed("100%")|noescape}
{/if}
{/if}
<div class="video-wowzer">
<img src="/assets/packages/static/openvk/img/videoico.png" />
<a href="/video{$attachment->getPrettyId()}">{$attachment->getName()}</a>