Repository navigation
Conversation
When a derivative image is narrower than its `w` descriptor (e.g. the source image is too small and upscaling is disabled), advertise its real width in the srcset instead, and drop entries that would duplicate a width already listed. Applies to responsive images and picture sources. Fixes pelican-plugins#53 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes #53
Problem
When a source image is narrower than a
srcsetentry'swdescriptor (and upscaling is disabled), the generated derivative ends up narrower than declared — but thesrcsetstill advertises the declared width. For a 1500px image with1000w/2000w/3000wentries, the browser is told it can pick a 3000px image, while the file is actually 1500px.Change
After processing each
srcsetentry, the actual width of the derivative is compared with itswdescriptor (new helperget_srcset_descriptor()):1500winstead of2000w).srcset, the entry is omitted.For the example from the issue the result is:
This applies to
responsive-imageand bothpicturecode paths. Density (x) descriptors are untouched, and if an image cannot be processed the declared descriptor is kept.Differences from the proposal in the issue
srcsetcannot mix a candidate without a descriptor withwcandidates. The derivative listed with its real width serves the same purpose while preserving format conversion and other operations.Tests
get_srcset_descriptor()pelican-bird.jpg, 1024px wide) andscale_out … Falseentries up to3000w<picture>test with a mocked undersized sourceREADME and
RELEASE.mdupdated.🤖 Generated with Claude Code