Repository navigation
Media: Preserve original_image metadata for large photos with EXIF rotation - #83785
CookieDarb wants to merge 1 commit into
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
Updated as activity occurs, without notifying anyone named here. Add the 🏷️ LabelsThis pull request needs exactly one label indicating its type, and has 0.
Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you. |
|
Tested this against my reproduction from #83757 (WP 7.1.2, Chrome 153, wp-env, only Gutenberg active), using the plugin zip from CI. With the PR, the Truepic photo (4032×3024, orientation 6) goes through one round of sideloads and gets finalized. The two controls (a large photo without rotation, a small rotated one) behave as before. One thing I noticed: on 24.0.0 I didn't get the single round from the issue this time, but the older behaviour where everything is sideloaded twice and never finalized. With this PR that didn't happen either. Looks good to me, thanks. |
f7f6f4e to
46f4194
Compare
|
#87135 builds on this PR. It uses the One thing to watch when rebasing: #83530 wrapped the |
46f4194 to
677a266
Compare
|
Thanks for the heads-up! Rebased onto latest |
What?
Closes #83757
Fixes the bug where
original_imagein attachment metadata points to an intermediate rotated file (...-rotated-1.jpg) instead of the untouched uploaded file for large photos with EXIF rotation uploaded via client-side media processing.Why?
In WordPress, large images exceeding the big image threshold (2560px) are scaled down and auto-rotated in a single step, preserving the untouched uploaded file as
original_image.In Gutenberg's client-side processing, large images with EXIF rotation were incorrectly treated as needing both a separate rotated file and a scaled file. Sideloading both files caused the intermediate rotated file to overwrite
original_imagein the attachment metadata, cutting off access to the true uploaded original file.How?
packages/upload-media/src/store/private-actions.ts:bigImageSizeThresholdusingcreateImageBitmapbefore the rotation step to determineneedsScaling.needsRotationtoexifOrientation !== 1 && ! needsScaling, ensuring that oversized images skip the separate rotated file and let the scaling step handle rotation, matching WordPress core.needsScalingin the scaled sideload section to avoid redundant bitmap decoding.packages/upload-media/src/store/test/private-actions.js:makeHarnessto accept store settings overrides.skips the rotated-original sideload for already-scaled imagesto mock dimensions exceedingbigImageSizeThreshold: 2560instead of relying on a mock filename.Testing Instructions
window.crossOriginIsolatedistruein browser console, or test onlocalhost/ HTTPS).truepic-20230212-camera.jpg[Orientation 6] mentioned in the issue).post-new.php).Before Fix - returns rotated image:
-rotated-1.jpgAfter Fix - returns the untouched raw upload.
Use of AI Tools
AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini
Used for: Investigating the root cause and aligning the fix with existing codebase patterns and unit tests. Final decisions and edits were made by me.