Repository navigation
[xExtension-ImageProxy] Respect the feed option to hide enclosures - #564
Merged
Merged
Conversation
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.
Alkarex
approved these changes
Oct 27, 2026
Member
|
Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
entry_before_displayhook proxied$entry->content(), which appends the thumbnail and enclosures by default, and stored the result as the new content. FreshRSS then renders it withcontent($withEnclosures)according to the Show enclosures option of the feed, but the enclosures were already part of the content, so with the extension enabled they were shown even for feeds where that option is disableddisplay_enclosureslogic as the FreshRSS views and APIs (e.g.index/normal.phtml,FreshRSS_Entry::toGReader(), the Fever API)Validation
End-to-end with FreshRSS
edge(PHP 8.5, SQLite) and a feed with a body image, an image<enclosure>and amedia:thumbnail, running theentry_before_displayhook and then$entry->content($feed->attributeBoolean('display_enclosures') ?? true)likeindex/normal.phtml:main: the thumbnail and the enclosure are still displayed (proxied)<p>Body <img src="https://wsrv.nl/?url=img.example%2Fbody.jpg" …></p>Also
composer run-script php-lint,phtml-lint,test-image-proxy,phpcsandphpstan(with../FreshRSS).tests/ImageProxyTest.phponly covers the static URL rewriting with stubbed configuration; covering the hook would need stubs forFreshRSS_Entry,FreshRSS_FeedandFreshRSS_Category, which conflict with the real classes that PHPStan analyses, so I validated this part end-to-end instead.