Fix: Skip scaled image sideload for images below big image threshold#75988
Draft
adamsilverstein wants to merge 1 commit intoWordPress:wp/7.0from
Draft
Fix: Skip scaled image sideload for images below big image threshold#75988adamsilverstein wants to merge 1 commit intoWordPress:wp/7.0from
adamsilverstein wants to merge 1 commit intoWordPress:wp/7.0from
Conversation
Add a dimension check using createImageBitmap() before queuing the scaled sideload. Only create the scaled version when the image width or height exceeds bigImageSizeThreshold, matching WordPress core's wp_create_image_subsizes() behavior. This prevents small images from incorrectly getting original_image metadata set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
DO NOT MERGE - testing only
Summary
createImageBitmap()before queuing the scaled image sideload ingenerateThumbnails()-scaledversion when the image width or height exceedsbigImageSizeThreshold, matching WordPress core'swp_create_image_subsizes()behaviorbig-image-size-threshold.spec.jsE2E test failure where small images were incorrectly gettingoriginal_imagemetadata setRoot cause
After #75817, the code unconditionally queued a "scaled" sideload for all images when
bigImageSizeThresholdwas set, regardless of actual image dimensions. The PHP handler then setmetadata['original_image']for any sideload withimage_size === 'scaled', even for images that didn't need scaling.Test plan
npm run test:e2e -- test/e2e/specs/editor/various/big-image-size-threshold.spec.jsoriginal_imagein attachment metadata-scaledversion is created correctly🤖 Generated with Claude Code