Skip to content

feat: revert lazy-loaded image attributes#273

Open
moon-jam wants to merge 1 commit intohexojs:masterfrom
moon-jam:fix/rss-lazyload-images
Open

feat: revert lazy-loaded image attributes#273
moon-jam wants to merge 1 commit intohexojs:masterfrom
moon-jam:fix/rss-lazyload-images

Conversation

@moon-jam
Copy link
Copy Markdown

data-src to src in feed content and descriptions

check list

  • Add test cases for the changes.
  • Passed the CI test.

Description

Many Hexo themes use front-end lazy-loading libraries (e.g., tuupola/lazyload), which replace the image src with a placeholder and move the actual URL to data-src. Since RSS readers don't execute JavaScript, these images appear broken in feeds.
This PR fixes this by reverting lazy-loaded attributes in the feed output:

  • Restores data-src (as well as data-srcset and data-sizes) back to standard src/srcset/sizes.
  • Removes the dummy placeholder src.
  • Adds a unit test to prevent regressions.
    This ensures images render correctly in RSS/Atom readers while keeping lazy-load intact on the blog itself.

Additional information

I'm completely open to feedback on this! If you think this reverting behavior should be implemented as an optional feature instead of a default (e.g., controlled via a configuration flag like feed.revert_lazyload: true), please let me know and I'll be more than happy to update the PR accordingly!

data-src to src in feed content and descriptions
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.

1 participant