Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions xExtension-YouTube/configure.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ declare(strict_types=1);
<input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
<div class="form-group">

<div class="group-controls">
<label class="checkbox" for="yt_autosize">
<input type="checkbox" id="yt_autosize" name="yt_autosize" <?= $this->isAutoSize() ? 'checked="checked"' : '' ?> />
<?= _t('ext.yt_videos.autosize') ?>
</label>
</div>

<label class="group-name" for="yt_height"><?= _t('ext.yt_videos.height') ?></label>
<div class="group-controls">
<input type="number" id="yt_height" name="yt_height" value="<?= $this->getHeight() ?>" min="50" />
Expand Down
27 changes: 23 additions & 4 deletions xExtension-YouTube/extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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']);
Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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 = '<iframe class="youtube-plugin-video"
style="height: ' . $this->height . 'px; width: ' . $this->width . 'px;"
width="' . $this->width . '"
height="' . $this->height . '"
$iframe = '<iframe ' . $iframeAttributes . '
src="' . $url . '"
frameborder="0"
referrerpolicy="strict-origin-when-cross-origin"
Expand Down Expand Up @@ -570,6 +588,7 @@ public function handleConfigureAction(): void {
$this->resetAllIcons();
break;
}
FreshRSS_Context::userConf()->_attribute('yt_player_autosize', Minz_Request::paramBoolean('yt_autosize'));
FreshRSS_Context::userConf()->_attribute('yt_player_height', Minz_Request::paramInt('yt_height'));
FreshRSS_Context::userConf()->_attribute('yt_player_width', Minz_Request::paramInt('yt_width'));
FreshRSS_Context::userConf()->_attribute('yt_show_content', Minz_Request::paramBoolean('yt_show_content'));
Expand Down
1 change: 1 addition & 0 deletions xExtension-YouTube/i18n/de/ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

return array(
'yt_videos' => array(
'autosize' => 'Automatische Größe des Players',
'height' => 'Höhe des Players',
'width' => 'Breite des Players',
'show_content' => 'Zeige den Inhalt des Feeds an',
Expand Down
1 change: 1 addition & 0 deletions xExtension-YouTube/i18n/en/ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

return array(
'yt_videos' => array(
'autosize' => 'Automatically size the player',
'height' => 'Player height',
'width' => 'Player width',
'show_content' => 'Display the feeds content',
Expand Down
1 change: 1 addition & 0 deletions xExtension-YouTube/i18n/fr/ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

return array(
'yt_videos' => array(
'autosize' => 'Taille automatique du lecteur',
'height' => 'Hauteur du lecteur',
'width' => 'Largeur du lecteur',
'show_content' => 'Afficher le contenu du flux',
Expand Down
1 change: 1 addition & 0 deletions xExtension-YouTube/i18n/pl/ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

return array(
'yt_videos' => array(
'autosize' => 'Automatyczny rozmiar odtwarzacza',
'height' => 'Wysokość odtwarzacza wideo',
'width' => 'Szerokość odtwarzacza wideo',
'show_content' => 'Wyświetlaj zawartość kanałów',
Expand Down
1 change: 1 addition & 0 deletions xExtension-YouTube/i18n/tr/ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

return array(
'yt_videos' => array(
'autosize' => 'Oynatıcıyı otomatik boyutlandır',
'height' => 'Oynatıcı yükseklik',
'width' => 'Oynatıcı genişlik',
'show_content' => 'Yayın içeriğini görüntüle',
Expand Down
2 changes: 1 addition & 1 deletion xExtension-YouTube/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "YouTube Video Feed",
"author": "Kevin Papst, Inverle",
"description": "Embed YouTube feeds inside article content.",
"version": "1.2.0",
"version": "1.3.0",
"entrypoint": "YouTube",
"type": "user"
}
4 changes: 4 additions & 0 deletions xExtension-YouTube/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.yt-player-autosize {
width: 100%;
aspect-ratio: 16 / 9;
}