Skip to content

[xExtension-ImageProxy] Respect the feed option to hide enclosures - #564

Merged
Alkarex merged 1 commit into
FreshRSS:mainfrom
NopeCharon:imageproxy-display-enclosures
Oct 27, 2026
Merged

Alkarex merged 1 commit into
FreshRSS:mainfrom
NopeCharon:imageproxy-display-enclosures

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

Summary

  • the entry_before_display hook proxied $entry->content(), which appends the thumbnail and enclosures by default, and stored the result as the new content. FreshRSS then renders it with content($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 disabled
  • only include the enclosures when the feed displays them, with the same display_enclosures logic as the FreshRSS views and APIs (e.g. index/normal.phtml, FreshRSS_Entry::toGReader(), the Fever API)
  • look the feed up in the cached categories first, like the views do, to avoid one database request per entry
  • when the enclosures are displayed the output is unchanged: they are still proxied and not duplicated
  • bump the extension version to 1.0.4 and add a changelog entry

Validation

End-to-end with FreshRSS edge (PHP 8.5, SQLite) and a feed with a body image, an image <enclosure> and a media:thumbnail, running the entry_before_display hook and then $entry->content($feed->attributeBoolean('display_enclosures') ?? true) like index/normal.phtml:

  • Show enclosures disabled, on main: the thumbnail and the enclosure are still displayed (proxied)
  • Show enclosures disabled, with this change: only <p>Body <img src="https://wsrv.nl/?url=img.example%2Fbody.jpg" …></p>
  • Show enclosures enabled: identical output before and after the change (body image, thumbnail and enclosure all proxied, once each)

Also composer run-script php-lint, phtml-lint, test-image-proxy, phpcs and phpstan (with ../FreshRSS).

tests/ImageProxyTest.php only covers the static URL rewriting with stubbed configuration; covering the hook would need stubs for FreshRSS_Entry, FreshRSS_Feed and FreshRSS_Category, which conflict with the real classes that PHPStan analyses, so I validated this part end-to-end instead.

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

Alkarex commented Oct 27, 2026

Copy link
Copy Markdown
Member

Thanks!

@Alkarex
Alkarex merged commit 40efdaf into FreshRSS:main Oct 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants