Skip to content

Commit

Permalink
Minor improvements in video attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
celestora committed Feb 7, 2023
1 parent 7ed870c commit a9d021b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Web/Models/VideoDrivers/VideoDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ abstract function getThumbnailURL(): string;

abstract function getURL(): string;

abstract function getEmbed(): string;
abstract function getEmbed(string $w = 600, string $h = 340): string;
}
6 changes: 3 additions & 3 deletions Web/Models/VideoDrivers/YouTubeVideoDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ function getURL(): string
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"
Expand Down
16 changes: 13 additions & 3 deletions Web/Presenters/templates/components/attachment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,19 @@
</a>
{/if}
{elseif $attachment instanceof \openvk\Web\Models\Entities\Video}
<div class="bsdn media" data-name="{$attachment->getName()}" data-author="{$attachment->getOwner()->getCanonicalName()}">
<video class="media" src="{$attachment->getURL()}"></video>
</div>
{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>
Expand Down

0 comments on commit a9d021b

Please sign in to comment.