Skip to content

Automatic feed channel icons feature for xExtension-YouTube#337

Merged
Alkarex merged 23 commits intoFreshRSS:masterfrom
Inverle:yt-channel-feed-icons
Aug 18, 2025
Merged

Automatic feed channel icons feature for xExtension-YouTube#337
Alkarex merged 23 commits intoFreshRSS:masterfrom
Inverle:yt-channel-feed-icons

Conversation

@Inverle
Copy link
Member

@Inverle Inverle commented Jun 16, 2025

Dependent on FreshRSS/FreshRSS#7646

Right now, the icon only gets set after the feed is added.
(the correct setting must be enabled in order for the icons to be downloaded)

TODO:

  • redownload icon whenever needed - for later release (downloading with proxy isn't tested)
  • add a button to set the icon for individual feeds (needs work in Implement custom feed favicons FreshRSS#7646)
  • add option to download icons for all of the channel feeds
    • show fetching progress and make individual requests for each feed with JS so that PHP doesn't timeout (necessary when there's a lot of feeds)
  • add option to reset all of the channel icons back to the YT icon
  • fix tests

@Inverle Inverle marked this pull request as draft June 18, 2025 03:08
Inverle and others added 2 commits June 30, 2025 09:35
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Alkarex pushed a commit to FreshRSS/FreshRSS that referenced this pull request Jun 30, 2025
Closes #3789, #6503

Icon setting when no custom icon is set yet:

![image](https://github.com/user-attachments/assets/28b07dd0-7dac-4c76-b1d7-77035f91a87a)

- `Change...` button opens a file dialog, and after selecting a file shows the chosen icon in the preview on the left. `Submit` must be clicked after selecting the icon.
- `Reset to default` changes the preview icon to the default one, and also requires `Submit` to be clicked to apply the changes.

Full list of changes:
- CSP now includes `blob:` in `img-src` for
   - `indexAction()` and `feedAction()` in `subscriptionController.php`
   - all of the view actions in `indexController.php`
- Introduce new attribute `customFavicon (boolean)` for feeds that indicates if the feed has a custom favicon
   - `hashFavicon()` in `Feed.php` is dependent on this attribute
      - `hashFavicon()` has a new parameter called `skipCache (boolean)` that allows the reset of the favicon hash for the Feed object
      - `resetFaviconHash()` just calls `hashFavicon(skipCache: true)`
- `f.php` URLs now have the format of `/f.php?h=XXXXX&t=cachebuster`, where the `t` parameter is only used for serving custom favicons
   - if `t` parameter is set, `f.php` returns a `Cache-Control: immutable` header
- `stripos` and `strpos` were changed to `str_contains` in various places (refactor)
- JS for handling the custom favicon configuration logic is in `extra.js` inside `init_update_feed()` which is called when feed configuration is opened from the aside or when the subscription management page with the feed is loaded
   - Server-side code for uploading the icon in `subscriptionController.php` under `feedAction()`
   - Errors that may occur during the setting of a custom favicon:
      - Unsupported image file type (handled only server-side with `isImgMime()`)
      - When the file is bigger than 1 MiB (default), handled both client-side and server-side
      - Standard feed error when `updateFeed()` fails
- JS vars `javascript_vars.phtml` are no longer escaped with `htmlspecialchars()`, instead with json encoding,
- CSS for disabled buttons was added
- Max favicon file size is configurable with the `max_favicon_upload_size` option in `config.php` (not exposed via UI)
- Custom favicons are currently deleted only when they are either reset to the default icon, or the feed gets deleted. They do not get deleted when the user deletes their account without removing their feeds first.
- ` faviconPrepare()` and `faviconRebuild()` are not allowed to be called when the `customFavicon` attribute is `true`
- New i18n strings:
   - `'sub.feed.icon' => 'Icon'`
   - `'sub.feed.change_favicon' => 'Change…'`
   - `'sub.feed.reset_favicon' => 'Reset to default'`
   - `'sub.feed.favicon_changed_by_ext' => 'The icon has been set by the <b>%s</b> extension.'`
   - `'feedback.sub.feed.favicon.too_large' => 'Uploaded icon is too large. The maximum file size is <em>%s</em>.'`
   - `'feedback.sub.feed.favicon.unsupported_format' => 'Unsupported image file format!'`
- Extension hook `custom_favicon_hash`
   - `setCustomFavicon()` method
   - `resetCustomFavicon()` method
   - `customFaviconExt` and `customFaviconDisallowDel` attributes
   - example of usage: FreshRSS/Extensions#337
- Extension hook `custom_favicon_btn_url`
   - Allows extensions to implement a button for setting a custom favicon for individual feeds by providing an URL. The URL will be sent a POST request with the `extAction` field set to either `query_icon_info` or `update_icon`, along with an `id` field which describes the feed's ID.
@Inverle Inverle marked this pull request as ready for review August 5, 2025 19:38
@Inverle Inverle requested a review from Alkarex August 5, 2025 19:38
headers: {
'Content-Type': 'application/json; charset=UTF-8'
}
}).then(resp => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not urgent, but I think it would be nicer to update to async / await at some point

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, I think it's good enough for now

@Alkarex
Copy link
Member

Alkarex commented Aug 5, 2025

@kevinpapst if you are around, any feedback here?

@Alkarex
Copy link
Member

Alkarex commented Aug 5, 2025

Ping @ImAReplicant, @pax0707

@pax0707
Copy link

pax0707 commented Aug 5, 2025

Tried it on some 300 yt feeds.
Works as expected

image

@Alkarex
Copy link
Member

Alkarex commented Aug 5, 2025

Tried it on some 300 yt feeds. Works as expected

Thanks for the quick feedback :-)

@Alkarex
Copy link
Member

Alkarex commented Aug 6, 2025

Let's merge after the release of FreshRSS 1.27.0

@Inverle
Copy link
Member Author

Inverle commented Aug 18, 2025

@Alkarex can be merged now

@Alkarex Alkarex merged commit 0a52621 into FreshRSS:master Aug 18, 2025
1 check passed
@Inverle Inverle deleted the yt-channel-feed-icons branch August 18, 2025 16:23
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.

3 participants