mirror of
https://github.com/FreshRSS/Extensions.git
synced 2026-11-04 10:48:40 +00:00
[xExtension-ImageProxy] Respect the feed option to hide enclosures (#564)
The `entry_before_display` hook proxied `$entry->content()`, which by default appends the thumbnail and enclosures of the entry to its content, and then stored the result as the new content. FreshRSS renders the content afterwards with `content($withEnclosures)` based on the "Show enclosures" option of the feed, but since the enclosures were already baked into the content, they were displayed even for feeds where that option is disabled, as soon as the extension was enabled. Only include the enclosures when the feed displays them, following the same `display_enclosures` logic as the FreshRSS views and APIs. The feed is looked up in the cached categories first, like the views do, to avoid one database request per entry. When enclosures are displayed, the output is unchanged: they are still proxied and not duplicated. Bump the extension version to 1.0.4.
This commit is contained in:
1 parent
41fd35253e
commit
40efdaf0d4
3 files changed
+6
-2
No files matched your search
@@ -6,6 +6,7 @@ To use it, upload this entire directory to the FreshRSS `./extensions` directory
|
||||
|
||||
## Changelog
|
||||
|
||||
* 1.0.4 Respect the feed option to hide enclosures
|
||||
* 1.0.3 Proxy the poster images of videos
|
||||
* 1.0.1 Replace deprecated HTML entity conversion on PHP 8.2+
|
||||
* 1.0 Breaking changes due to significant code upgrade: settings must be saved again
|
||||
|
||||
@@ -184,8 +184,11 @@ final class ImageProxyExtension extends Minz_Extension {
|
||||
* @throws FreshRSS_Context_Exception
|
||||
*/
|
||||
public static function setImageProxyHook(FreshRSS_Entry $entry): FreshRSS_Entry {
|
||||
// The enclosures become part of the content, so only include them if the feed displays them
|
||||
// We most likely already have the feed object in cache, otherwise make a request
|
||||
$feed = FreshRSS_Category::findFeed(FreshRSS_Context::categories(), $entry->feedId()) ?? $entry->feed();
|
||||
$entry->_content(
|
||||
self::swapUris($entry->content())
|
||||
self::swapUris($entry->content($feed?->attributeBoolean('display_enclosures') ?? true))
|
||||
);
|
||||
|
||||
return $entry;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "Image Proxy",
|
||||
"author": "Frans de Jonge",
|
||||
"description": "No insecure content warnings or disappearing images.",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"entrypoint": "ImageProxy",
|
||||
"type": "user"
|
||||
}
|
||||
Reference in new issue
Block a user