Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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="<?php echo 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" value="1" <?php echo $this->isAutoSize() ? 'checked' : ''; ?>>
<?php echo _t('ext.yt_videos.autosize'); ?>
</label>
</div>

<label class="group-name" for="yt_height"><?php echo _t('ext.yt_videos.height'); ?></label>
<div class="group-controls">
<input type="number" id="yt_height" name="yt_height" value="<?php echo $this->getHeight(); ?>" min="50" data-leave-validation="1">
Expand Down
29 changes: 28 additions & 1 deletion 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 we set the Youtube iframe to autosize
*/
private bool $autoSize = false;
/**
* Video player width
*/
Expand All @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -181,7 +201,13 @@ public function getHtml(FreshRSS_Entry $entry, string $url): string
{
$content = '';

$iframe = '<iframe class="youtube-plugin-video"
if ($this->autoSize) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed the class youtube-plugin-video. Can you re-add it, to not break existing customizations?

$class = "yt_autosize_true";
} else {
$class = "yt_autosize_false";
}

$iframe = '<iframe class="' . $class . '"
style="height: ' . $this->height . 'px; width: ' . $this->width . 'px;"
width="' . $this->width . '"
height="' . $this->height . '"
Expand Down Expand Up @@ -252,6 +278,7 @@ public function handleConfigureAction(): void
$this->registerTranslates();

if (Minz_Request::isPost()) {
FreshRSS_Context::userConf()->_attribute('yt_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' => 'Autogröße des Players',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'autosize' => 'Autogröße des Players',
'autosize' => 'Automatische Größe des Players',

'height' => 'Höhe des Players',
'width' => 'Breite des Players',
'updates' => 'Die neueste Version des Plugins findest Du bei',
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' => 'Player autosize',
'height' => 'Player height',
'width' => 'Player width',
'updates' => 'You can find the latest extension version at',
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',
'updates' => 'Vous pouvez trouver la dernière mise à jour de l’extension sur ',
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ı otomatik boyutlandırma',
'height' => 'Oynatıcı yükseklik',
'width' => 'Oynatıcı genişlik',
'updates' => 'En son uzantı sürümünü şu adreste bulabilirsiniz:',
Expand Down
5 changes: 5 additions & 0 deletions xExtension-YouTube/static/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.yt_autosize_true {
height: 100%;
Comment thread
intriguedlife marked this conversation as resolved.
Outdated
width: 100%;
aspect-ratio: 16 / 9;
}