Skip to content

Fix: Skip scaled image sideload for images below big image threshold#75988

Draft
adamsilverstein wants to merge 1 commit intoWordPress:wp/7.0from
adamsilverstein:wp/7.0
Draft

Fix: Skip scaled image sideload for images below big image threshold#75988
adamsilverstein wants to merge 1 commit intoWordPress:wp/7.0from
adamsilverstein:wp/7.0

Conversation

@adamsilverstein
Copy link
Member

@adamsilverstein adamsilverstein commented Feb 27, 2026

DO NOT MERGE - testing only

Summary

  • Adds a dimension check using createImageBitmap() before queuing the scaled image sideload in generateThumbnails()
  • Only creates the -scaled version when the image width or height exceeds bigImageSizeThreshold, matching WordPress core's wp_create_image_subsizes() behavior
  • Fixes the big-image-size-threshold.spec.js E2E test failure where small images were incorrectly getting original_image metadata set

Root cause

After #75817, the code unconditionally queued a "scaled" sideload for all images when bigImageSizeThreshold was set, regardless of actual image dimensions. The PHP handler then set metadata['original_image'] for any sideload with image_size === 'scaled', even for images that didn't need scaling.

Test plan

  • Run npm run test:e2e -- test/e2e/specs/editor/various/big-image-size-threshold.spec.js
  • Confirm all 3 tests pass (above threshold scaled, below threshold not scaled, custom naming)
  • Upload a small image (below 2560px) and verify no original_image in attachment metadata
  • Upload a large image (above 2560px) and verify -scaled version is created correctly

🤖 Generated with Claude Code

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

1 participant