feat: lift WordPress srcset 2048px ceiling for configured retina widths - #292
Merged
Conversation
wp_calculate_image_srcset() excludes any candidate wider than the max_srcset_image_width filter (default 2048px) unless the width matches the requested size. Configured @nx variants above 2048px were therefore generated on disk but silently dropped from the emitted srcset. SrcsetWidthLimit reads the normalized image-size roster on boot and, when the largest configured width exceeds 2048px, registers a max_srcset_image_width filter returning max(current, largestWidth) so a higher external value is never lowered. Output stays byte-identical when no configured width exceeds the default.
The recent wordpress-stubs bump types wp_get_registered_image_subsizes() and wp_get_upload_dir() precisely, making the defensive is_numeric/ is_string guards and ?? fallbacks provably dead. Remove them and tighten the normalizer's return shape to int<0, max> so add_image_size() accepts the widths without an argument.type error. No runtime behavior change.
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.
Problem
WordPress'
wp_calculate_image_srcset()drops any srcset candidate wider thanmax_srcset_image_width(default 2048px) unless the width matches the requested size exactly. Sproutset's@Nxvariant feature generates files above 2048px, which were then silently excluded from the emitted srcset — wasted generation and broken retina intent above 2048.Change
SrcsetWidthLimitreads the normalizedimage_sizesroster on boot and, when the largest configured width exceeds 2048, registers amax_srcset_image_widthfilter returningmax(current, largest).max(current, …)never lowers a value another plugin set higher.Tests
Unit + integration (real WP) cover ceiling computation and live filter behavior, mapped 1:1 in
specs/image-size-registration.md.