-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Add lazy loading and async decoding to blog images #2173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add lazy loading and async decoding to blog images #2173
Conversation
- Added add_lazy_loading filter in blog_extras.py - Applied filter to object.body_html in blog templates (entry_detail.html, meeting_detail.html) - Added unit tests in blog/tests/test_lazy_loading.py - Added test settings (settings/test.py) for faster CI runs - Updated foundation template for consistency Fixes django#2154
3b5fdad
to
85c6eef
Compare
for more information, see https://pre-commit.ci
Hi, this is my first contribution. Please let me know if any further changes are needed. |
Thanks for submitting a PR @AnmolChauhan1234 ! As a next step, someone from the Website WG will review this PR, and leave any comments or changes that might be needed or approve the PR for merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AnmolChauhan1234 thank you for giving this a go! This feels very heavy-handed to me though, I’m not sure how you arrived at this solution? I would have preferred to see simpler approaches attempted before we move to re-parsing and rewriting all HTML in a filter.
There are also a lot of unrelated and unnecessary changes in your PR, it’s not clear to me if you did this with an AI coding tool and didn’t check the output?
I would like to see this attempted with customizations to our markdown and reStructuredText rendering. Unless there is a reason why it’s not possible? We really shouldn’t be rewriting all blog post HTML just to add one attribute to one type of element.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no images in this content so those changes are irrelevant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t understand what this file is doing here.
Hi @AnmolChauhan1234 , are you still working on this? Are you able to address the comments Thibaud made last month? |
Changes
Added add_lazy_loading filter in blog_extras.py
Applied filter to object.body_html in blog templates (entry_detail.html)
Added tests in blog/tests/test_lazy_loading.py to ensure:
Attributes are added
Existing attributes are preserved
Multiple images are handled
Non-image tags remain untouched
Added test settings (settings/test.py) for faster CI
Updated foundation template for consistency
Issue
Fixes #2154
Impact
Ensures images are lazy-loaded by default, improving initial load times without breaking existing functionality.