-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Add AVIF, WebP and MozJPEG output encoding support #75081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
adamsilverstein
wants to merge
98
commits into
trunk
Choose a base branch
from
74364-add-output-format-support-and-mozjpeg-default-4
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Add AVIF, WebP and MozJPEG output encoding support #75081
adamsilverstein
wants to merge
98
commits into
trunk
from
74364-add-output-format-support-and-mozjpeg-default-4
+5,012
−94
Conversation
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
…upload media types
…n, transparency check and resizing
Pass the big image size threshold (default 2560) from the REST API through the settings chain to the upload-media store. This enables client-side scaling of large images before upload, matching WordPress core's behavior. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When an image exceeds the big image size threshold (default 2560px), scale it down before upload with a '-scaled' suffix. This matches WordPress core's behavior in wp_create_image_subsizes(). - Add isThresholdResize flag to ResizeCrop operation args - Update vipsResizeImage to support '-scaled' suffix - Update resizeCropItem to pass through threshold flag - prepareItem now adds ResizeCrop operation for threshold scaling Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add tests to verify that: - Images larger than the threshold (default 2560) are scaled down - The -scaled suffix is added to scaled images - Images smaller than the threshold are not modified Tests skip when cross-origin isolation is not enabled, as the vips library requires SharedArrayBuffer. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Use sourceFile instead of file when generating thumbnails to match WordPress core behavior. This ensures thumbnails are created from the original high-resolution image rather than the scaled version. Also adds E2E test assertions to verify original_image metadata is preserved and thumbnails are generated with expected dimensions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This adds client-side EXIF orientation handling that mirrors WordPress core's server-side rotation behavior: - Add exif_orientation field to REST API response for images - Disable server-side EXIF rotation when generate_sub_sizes=false so client can handle rotation using the returned orientation value - Add rotateImage function to vips package supporting all 8 EXIF orientation values (rotations and flips) - Add vipsRotateImage wrapper in upload-media store utils - Add Rotate operation type and rotateItem action handler - Update generateThumbnails to sideload rotated version for images that need rotation but weren't scaled (matching -rotated suffix) - Fix Jest config to resolve @wordpress/vips/worker module for tests - Add tests for vipsRotateImage function The implementation ensures: - Images scaled via bigImageSizeThreshold are auto-rotated by vips - Small images needing rotation get a -rotated version sideloaded - Thumbnails are auto-rotated by vips during generation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
FileList is an array-like object that doesn't have array methods. Convert it to a proper array before passing to addItems. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ploads Wraps the block editor children with UploadSaveLockWrapper component that uses the useUploadSaveLock hook to properly manage post save locks based on upload state. This ensures the save button state correctly reflects ongoing media uploads. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add the useUploadSaveLock hook that manages post save and autosave locks based on upload state. The hook monitors the upload-media store and locks post saving when uploads are in progress, preventing users from publishing or saving while files are still uploading. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Remove direct import from @wordpress/editor to prevent circular dependency between block-editor and editor packages. Instead, dynamically check if the editor store is registered and access it through the registry. This ensures the hook works safely in contexts where the editor store may not be available (e.g., standalone block editor widgets). Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit implements output format conversion for client-side media processing, enabling generation of modern image formats (AVIF, WebP) and modern JPEG codecs (MozJPEG) during upload. Key changes: - Add TranscodeImage operation type for format conversion - Add imageOutputFormats, jpegInterlaced, pngInterlaced, gifInterlaced settings that flow from PHP REST API through the settings stack - Implement transcodeImageItem action using vipsConvertImageFormat - Update prepareItem to check format mapping and add TranscodeImage operations when needed - Add transparency check for PNG->JPEG to preserve alpha channels - Apply format conversion to generated thumbnails - Add MozJPEG optimizations (optimize_coding, quant_table) for JPEG output, providing ~10-15% smaller file sizes The implementation respects WordPress's image_editor_output_format filter for format mapping configuration. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix blob URL memory leak using try/finally pattern for transparency check - Add format validation before ImageFormat type assertion - Improve JSDoc for Settings interface properties - Add clarifying comment for empty filename in image_editor_output_format filter Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…rmat-support-and-mozjpeg-default-4
Member
Author
|
Size Change: +3.75 MB (+125.22%) 🆘 Total Size: 6.75 MB
ℹ️ View Unchanged
|
4 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[Package] Block editor
/packages/block-editor
[Package] Core data
/packages/core-data
[Package] Editor
/packages/editor
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 #74364
Summary
This PR adds output format conversion support for client-side media processing, enabling generation of modern image formats during upload:
Key changes:
TranscodeImageoperation type for format conversionimageOutputFormats,jpegInterlaced,pngInterlaced,gifInterlaced) that flow from PHP REST APItranscodeImageItemaction using vipsConvertImageFormatprepareItemto check format mapping and add TranscodeImage operationsoptimize_coding,quant_table) for JPEG outputThe implementation respects WordPress's
image_editor_output_formatfilter for format mapping configuration.Test plan
image_editor_output_formatfilter to convert JPEG→WebP and verify conversion🤖 Generated with Claude Code