From cbec4b549fa8e5ac490d65f03bfab30a37a5a7cb Mon Sep 17 00:00:00 2001 From: celestora Date: Tue, 7 Feb 2023 22:39:07 +0200 Subject: [PATCH] Minor improvements in video attachments --- Web/Models/VideoDrivers/VideoDriver.php | 2 +- Web/Models/VideoDrivers/YouTubeVideoDriver.php | 6 +++--- .../templates/components/attachment.xml | 16 +++++++++++++--- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Web/Models/VideoDrivers/VideoDriver.php b/Web/Models/VideoDrivers/VideoDriver.php index 141e738b..ca9fb74b 100644 --- a/Web/Models/VideoDrivers/VideoDriver.php +++ b/Web/Models/VideoDrivers/VideoDriver.php @@ -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; } diff --git a/Web/Models/VideoDrivers/YouTubeVideoDriver.php b/Web/Models/VideoDrivers/YouTubeVideoDriver.php index 93aee0e5..1b9940e6 100644 --- a/Web/Models/VideoDrivers/YouTubeVideoDriver.php +++ b/Web/Models/VideoDrivers/YouTubeVideoDriver.php @@ -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 << {/if} {elseif $attachment instanceof \openvk\Web\Models\Entities\Video} -
- -
+ {if $attachment->getType() === 0} +
+ +
+ {else} + {var $driver = $attachment->getVideoDriver()} + {if !$driver} + {_version_incompatibility} + {else} + {$driver->getEmbed("100%")|noescape} + {/if} + {/if} +