Skip to content

Conversation

AnmolChauhan1234
Copy link

Changes

  1. Added add_lazy_loading filter in blog_extras.py

  2. Applied filter to object.body_html in blog templates (entry_detail.html)

  3. 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

  4. Added test settings (settings/test.py) for faster CI

  5. Updated foundation template for consistency

Issue

Fixes #2154

Impact

Ensures images are lazy-loaded by default, improving initial load times without breaking existing functionality.

- 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
@AnmolChauhan1234 AnmolChauhan1234 force-pushed the feat/lazy-load-blog-images branch from 3b5fdad to 85c6eef Compare August 19, 2025 19:42
@AnmolChauhan1234
Copy link
Author

Hi, this is my first contribution. Please let me know if any further changes are needed.

@SaptakS
Copy link
Contributor

SaptakS commented Aug 20, 2025

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.

Copy link
Member

@thibaudcolas thibaudcolas left a 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.

Copy link
Member

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

Copy link
Member

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.

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.

Lazy-loading for images in blog content
3 participants