Repository navigation
[xExtension-ImageProxy] Proxy the thumbnails shown in the list of articles - #579
Open
NopeCharon wants to merge 1 commit into
Open
NopeCharon wants to merge 1 commit into
NopeCharon wants to merge 1 commit into
Conversation
…icles The thumbnails that FreshRSS shows in the list of articles (when the "thumbnail" display option is enabled) come from the `thumbnail` attribute of the entry (e.g. an item-level `<media:thumbnail>`) or from the thumbnails of its enclosures (e.g. `<media:thumbnail>` inside a `<media:group>`, as in YouTube feeds). The extension only proxied the content, so these thumbnails were still loaded directly from the source. The `entry_before_display` hook now also proxies those URLs. They are stored HTML-encoded, so the new `getProxyImageHtmlUri()` decodes them before proxying and encodes the result again. When the enclosures are displayed, FreshRSS appends the thumbnail to the content unless its URL is found there. The thumbnail attribute is therefore only proxied when the proxied URL is part of the proxied content (which is the case when the content shows the thumbnail as an image), so that it is never displayed twice. The thumbnails of enclosures are not compared to the content and are always proxied. Bump the version to 1.1.1 and add a changelog entry. Fixes FreshRSS#200
Member
|
Let's finalise #578 first |
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
With the thumbnail display option enabled, the list of articles still loaded the thumbnails directly from the source, even though the article content was proxied (#200, also mentioned in #206). FreshRSS takes these thumbnails from:
thumbnailattribute of the entry, e.g. an item-level<media:thumbnail><media:thumbnail>inside a<media:group>, as in YouTube feedsThe
entry_before_displayhook now proxies the first two as well:getProxyImageHtmlUri()decodes them, proxies them and encodes the result again (e.g.?w=1&h=2, or the&of a proxy URL like the nginx example in the README)thumbnailattribute is only proxied when the proxied URL is found in the proxied content, which is the case when the content shows the thumbnail as an image. If the content only links to the image (<a href="…">), the thumbnail keeps its original URL instead of being shown twice. When the enclosures are hidden, the thumbnail is always proxiedImage enclosures used as a thumbnail when the feed has no thumbnail are not changed: proxying them would change the enclosure URLs that the APIs return.
Fixes #200
Validation
php tests/ImageProxyTest.phpon PHP 8.1 and 8.5 (44 assertions). The new test fails onmain(getProxyImageHtmlUri()does not exist)edge(PHP 8.5, SQLite) and the extension enabled. I used a local feed with an item<media:thumbnail>(with&in its URL), a<media:group>thumbnail, a thumbnail that is also a body image, and a thumbnail that the body only links to. Then I fetched the normal view with the landscape thumbnails enabled:main, all four list thumbnails use the original URLsmain, so no image is duplicatedproxy_url=https://www.example.org/proxy?key=changeme&url=,scheme_include= 1 andurl_encode= 0, the thumbnails are proxied and correctly encoded (&), with no duplicatesa=rss) now also proxies<media:thumbnail>, like it already proxied the descriptionphp-lint,phpcs,phpstan(with../FreshRSS, on PHP 8.1 and 8.5) andmarkdownlint