Repository navigation
fix: retain srcset width for duplicate image URLs - #2400
Open
linjiaye929 wants to merge 1 commit into
Open
linjiaye929 wants to merge 1 commit into
linjiaye929 wants to merge 1 commit into
Conversation
linjiaye929
marked this pull request as ready for review
October 16, 2026 07:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An image such as
<img src="photo.jpg" srcset="photo.jpg 640w" alt="Photo">loses its declared width: thesrcentry is added first, and URL deduplication discards the richersrcsetentry.Keep one variant per URL, but fill its missing width from a later source. Existing widths, variant order, and filtering stay unchanged. This preserves the srcset width descriptor; it does not measure image dimensions.
List of files changed and why
content_scraping_strategy.py: retain metadata while deduplicating variants.tests/test_image_variant_width.py: cover public scraping and serialized results.How Has This Been Tested?
45 focused tests passed: 14 input scenarios, one legacy-alias smoke test, and 30 existing scraper regressions. Cases include distinct URLs, first-present width precedence, zero/invalid descriptors, and lazy-loading attributes. No network or model service was used; the full browser/integration suite was not run.
New-test Black and diff checks pass. Source-range Black reports existing whitespace differences also present on the baseline; unrelated formatting is unchanged.
AI assistance was used for investigation, implementation, tests, and review.
Checklist
Hosted status (2026-10-16 07:08 UTC): no code/test checks are reported for this head. The Discord notification workflow requires maintainer action. Validation above is local.