From 6fe50ddd1e02e06e755fb8ef4eb0fe6086a97402 Mon Sep 17 00:00:00 2001 From: intriguedlife <39467654+intriguedlife@users.noreply.github.com> Date: Sat, 8 Feb 2025 20:32:27 +0100 Subject: [PATCH 1/5] [xExtension-YouTube] add player autosize feature --- xExtension-YouTube/configure.phtml | 7 +++++++ xExtension-YouTube/extension.php | 29 ++++++++++++++++++++++++++++- xExtension-YouTube/i18n/de/ext.php | 1 + xExtension-YouTube/i18n/en/ext.php | 1 + xExtension-YouTube/i18n/fr/ext.php | 1 + xExtension-YouTube/i18n/tr/ext.php | 1 + xExtension-YouTube/static/style.css | 5 +++++ 7 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 xExtension-YouTube/static/style.css diff --git a/xExtension-YouTube/configure.phtml b/xExtension-YouTube/configure.phtml index 8828fe7d..8895abc7 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 c8bec521..400b0918 100644 --- a/xExtension-YouTube/extension.php +++ b/xExtension-YouTube/extension.php @@ -9,6 +9,10 @@ */ final class YouTubeExtension extends Minz_Extension { + /** + * Whether we set the Youtube iframe to autosize + */ + private bool $autoSize = false; /** * Video player width */ @@ -32,6 +36,8 @@ final class YouTubeExtension extends Minz_Extension #[\Override] public function init(): void { + Minz_View::appendStyle($this->getFileUrl('style.css', 'css')); + $this->registerHook('entry_before_display', [$this, 'embedYouTubeVideo']); $this->registerHook('check_url_before_add', [self::class, 'convertYoutubeFeedUrl']); $this->registerTranslates(); @@ -63,6 +69,11 @@ public function loadConfigValues(): void return; } + $autoSize = FreshRSS_Context::userConf()->attributeBool('yt_autosize'); + if ($autoSize !== null) { + $this->autoSize = $autoSize; + } + $width = FreshRSS_Context::userConf()->attributeInt('yt_player_width'); if ($width !== null) { $this->width = $width; @@ -84,6 +95,15 @@ public function loadConfigValues(): void } } + /** + * Returns whether this extension enables autosize for the YouTube player iframe. + * You have to call loadConfigValues() before this one, otherwise you get default values. + */ + 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. @@ -181,7 +201,13 @@ public function getHtml(FreshRSS_Entry $entry, string $url): string { $content = ''; - $iframe = ''; diff --git a/xExtension-YouTube/static/style.css b/xExtension-YouTube/static/style.css index bec82a83..3caea388 100644 --- a/xExtension-YouTube/static/style.css +++ b/xExtension-YouTube/static/style.css @@ -1,5 +1,4 @@ -.yt_autosize_true { - height: 100%; +.yt_player_autosize { width: 100%; aspect-ratio: 16 / 9; } \ No newline at end of file From 94a9396b43cc0c70c8e1f8f6c4341d20ca12964c Mon Sep 17 00:00:00 2001 From: intriguedlife <39467654+intriguedlife@users.noreply.github.com> Date: Sun, 9 Feb 2025 00:23:09 +0100 Subject: [PATCH 5/5] [xExtension-YouTube] CSS correction 3 --- xExtension-YouTube/static/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xExtension-YouTube/static/style.css b/xExtension-YouTube/static/style.css index ec5312a3..aaf1420a 100644 --- a/xExtension-YouTube/static/style.css +++ b/xExtension-YouTube/static/style.css @@ -1,4 +1,4 @@ -.yt_autosize_true { +.yt_player_autosize { width: 100%; aspect-ratio: 16 / 9; } \ No newline at end of file