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
3 changes: 3 additions & 0 deletions xExtension-YouTube/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ With activated Youtube extension:

## Changelog

1.4.1:
- Fixed the original thumbnail, description and enclosures of the feed being appended below the video

1.4.0:
- Added an option to disable embedding videos, e.g. to only use the channel icons and URL conversion

Expand Down
27 changes: 26 additions & 1 deletion xExtension-YouTube/extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,31 @@ private function hasEnclosureStructure(string $content): bool {
|| stripos($content, 'enclosure-description') !== false;
}

/**
* Returns hidden references to the URLs of the thumbnail and enclosures of an entry.
* When displaying an entry, FreshRSS appends the thumbnail and enclosures whose URL is not found in the content,
* which would show them again after the video player that replaces them.
*/
private function getEnclosureReferences(FreshRSS_Entry $entry): string {
$urls = [];
$thumbnail = $entry->thumbnail(searchEnclosures: false);
if ($thumbnail !== null) {
$urls[] = $thumbnail['url'];
}
foreach ($entry->enclosures() as $enclosure) {
$urls[] = $enclosure['url'];
}

$references = '';
foreach (array_unique($urls) as $url) {
if ($url === '') {
continue;
}
$references .= '<p hidden data-xextension-youtube-original-src="' . $url . '"></p>';
}
return $references;
}

/**
* Returns an HTML <iframe> for a given URL for the configured width and height, with content ignored, appended or formatted.
*/
Expand Down Expand Up @@ -553,7 +578,7 @@ public function getHtml(FreshRSS_Entry $entry, string $url): string {
}
}

return $content;
return $content . $this->getEnclosureReferences($entry);
}

/**
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.4.0",
"version": "1.4.1",
"entrypoint": "YouTube",
"type": "user"
}