Skip to content

[html] convertLazyLoading: Add parseSrcset()#4503

Merged
dvikan merged 3 commits intoRSS-Bridge:masterfrom
ORelio:patch-2
Mar 31, 2025
Merged

[html] convertLazyLoading: Add parseSrcset()#4503
dvikan merged 3 commits intoRSS-Bridge:masterfrom
ORelio:patch-2

Conversation

@ORelio
Copy link
Contributor

@ORelio ORelio commented Mar 30, 2025

The convertLazyLoading() function converts lazy loading images with multiple sources (e.g. srcset attribute) back to regular <img> elements with a fixed src URL for use by feed readers. Currently, it simply separate fields by splitting by comma, but properly parsing srcset the attribute is more tricky that it seems, because URLs can also contain commas like this:

srcset="image.png?resize=640,640 640w,image.png?resize=960,960 960w,image.png?resize=1024,1024 1024w"

This PR aims at implementing srcset parsing closer to the specifications to properly retrieve the largest image.
https://html.spec.whatwg.org/multipage/images.html#parse-a-srcset-attribute

ORelio added 2 commits March 30, 2025 18:47
Add srcset parser closer to the specifications
@dvikan
Copy link
Contributor

dvikan commented Mar 30, 2025

you can typehint function params

plese check return value of preg_match_all

@ORelio
Copy link
Contributor Author

ORelio commented Mar 31, 2025

Done!

@dvikan dvikan merged commit 26a4c25 into RSS-Bridge:master Mar 31, 2025
9 checks passed
floviolleau pushed a commit to floviolleau/rss-bridge that referenced this pull request Aug 18, 2025
* [html] convertLazyLoading: Add parseSrcset()

Add srcset parser closer to the specifications

* [html] code linting

* [html] parseSrcset: Add type hints, check preg_match_all
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