diff --git a/xExtension-YouTube/configure.phtml b/xExtension-YouTube/configure.phtml index f4a7fe83..5a4b15b8 100644 --- a/xExtension-YouTube/configure.phtml +++ b/xExtension-YouTube/configure.phtml @@ -6,6 +6,13 @@ declare(strict_types=1);
+
+ +
+
diff --git a/xExtension-YouTube/extension.php b/xExtension-YouTube/extension.php index d76d928f..199a4c3e 100644 --- a/xExtension-YouTube/extension.php +++ b/xExtension-YouTube/extension.php @@ -9,6 +9,10 @@ */ final class YouTubeExtension extends Minz_Extension { + /** + * Whether the video player should use responsive sizing + */ + private bool $autoSize = false; /** * Video player width */ @@ -35,6 +39,7 @@ final class YouTubeExtension extends Minz_Extension */ #[\Override] public function init(): void { + Minz_View::appendStyle($this->getFileUrl('style.css')); $this->registerHook('entry_before_display', [$this, 'embedYouTubeVideo']); $this->registerHook('check_url_before_add', [self::class, 'convertYoutubeFeedUrl']); $this->registerHook('custom_favicon_hash', [$this, 'iconHashParams']); @@ -312,6 +317,11 @@ public function loadConfigValues(): void { return; } + $autoSize = FreshRSS_Context::userConf()->attributeBool('yt_player_autosize'); + if ($autoSize !== null) { + $this->autoSize = $autoSize; + } + $width = FreshRSS_Context::userConf()->attributeInt('yt_player_width'); if ($width !== null) { $this->width = $width; @@ -338,6 +348,14 @@ public function loadConfigValues(): void { } } + /** + * Returns whether responsive sizing is enabled for the video player iframe. + * You have to call loadConfigValues() before this one, otherwise you get the default value. + */ + public function isAutoSize(): bool { + return $this->autoSize; + } + /** * Returns the width in pixel for the YouTube player iframe. * You have to call loadConfigValues() before this one, otherwise you get default values. @@ -446,11 +464,11 @@ private function hasEnclosureStructure(string $content): bool { */ public function getHtml(FreshRSS_Entry $entry, string $url): string { $content = ''; + $iframeAttributes = $this->autoSize + ? 'class="youtube-plugin-video yt-player-autosize"' + : 'class="youtube-plugin-video" width="' . $this->width . '" height="' . $this->height . '"'; - $iframe = '