#64597 closed enhancement (fixed)
Client Site Media: PHP backports from Gutenberg
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | trunk |
| Component: | Editor | Keywords: | has-patch gutenberg-merge |
| Focuses: | Cc: |
Description
Description
This ticket adds REST API index data and preloaded paths for the client-side media processing feature being developed in Gutenberg.
Client-side media processing allows the browser to handle image resizing, thumbnail generation, and format conversion using WebAssembly (via the vips library), reducing server load and improving upload performance.
Changes
- REST API Index (
WP_REST_Server::get_index()): Adds media processing configuration fields to the REST API root index response for users with theupload_filescapability.
- Preload Paths: The post editor (
edit-form-blocks.php) and site editor (site-editor.php) now preload these fields.
New Fields
The following settings are now available in the REST API index (for authorized users) and preloaded in the editors:
image_sizes- Available image size configurations for thumbnail generationimage_size_threshold- Big image size threshold (default 2560px) for automatic scaling of large imagesimage_output_formats- Output format mappings for image conversion (e.g., JPEG to WebP)jpeg_interlaced- Whether to use progressive/interlaced JPEG encodingpng_interlaced- Whether to use interlaced PNG encodinggif_interlaced- Whether to use interlaced GIF encoding
These preloaded paths prevent additional REST API requests when the editor loads, improving performance.
Related Gutenberg PRs
- - Create sub-sized images(https://github.com/WordPress/gutenberg/pull/74566)
- - Add image output formats and interlace settings to REST API client(https://github.com/WordPress/gutenberg/pull/74908)
- - Media: Graduate client-side media processing from experimental(https://github.com/WordPress/gutenberg/pull/75112)
Tracking Issue
- - Graduate Client Side Media out of experiments(https://github.com/WordPress/gutenberg/issues/75062)
Testing
REST API Index
- As an admin user, make a GET request to
/wp-json/(the REST API root) - Verify the response includes
image_sizes,image_size_threshold,image_output_formats,jpeg_interlaced,png_interlaced, andgif_interlaced - As a subscriber (without
upload_filescapability), verify these fields are NOT present
Editor Preloading
- Open the post editor or site editor
- Check the Network tab in browser DevTools
- Look for the preloaded
/?_fields=...request - Verify the response includes the new image settings
Patch
GitHub PR: https://github.com/WordPress/wordpress-develop/pull/XXXXX
Change History (14)
This ticket was mentioned in PR #10868 on WordPress/wordpress-develop by @adamsilverstein.
5 weeks ago
#1
@adamsilverstein commented on PR #10868:
4 weeks ago
#4
Sorry for what may be an unsolicited early review, as the PR is still a draft.
No worries, happy to have your feedback. Indeed I started working on this pr before the Gutenberg work had merged to get ahead and be more prepared - so it may change a bit, but probably not much at this point.
@andrewserong commented on PR #10868:
3 weeks ago
#5
Just a quick comment: it looks like this accidentally removes the ca-bundle.crt file, so I assume needs a rebase?
@adamsilverstein commented on PR #10868:
3 weeks ago
#6
Just a quick comment: it looks like this accidentally removes the
ca-bundle.crtfile, so I assume needs a rebase?
oh, i thought i had added that file. will fix. Also figured out why this isn't working, fix incoming.
@adamsilverstein commented on PR #10868:
3 weeks ago
#7
Just a quick comment: it looks like this accidentally removes the
ca-bundle.crtfile, so I assume needs a rebase?
rebased and fixed.
@adamsilverstein commented on PR #10868:
3 weeks ago
#8
This is ready for additional testing, client side processing is now working as expected. In addition to smoke testing as is, it would be good to test with wp_is_client_side_media_processing_enabled set to false to verify server side processing kicks in as expected.
@adamsilverstein commented on PR #10868:
3 weeks ago
#9
@westonruter I believe I have addressed all outstanding feedback (except the output mapping one I will work on in a follow up). Can you give it another spin?
@mukesh27 commented on PR #10868:
3 weeks ago
#10
@adamsilverstein have you checked why unit tests are failed?
@adamsilverstein commented on PR #10868:
3 weeks ago
#11
@adamsilverstein[[Image(chrome-extension://hgomfjikakokcbkjlfgodhklifiplmpg/images/wp-logo.png)]] have you checked why unit tests are failed?
looking now...
@adamsilverstein commented on PR #10868:
3 weeks ago
#12
@adamsilverstein[[Image(chrome-extension://hgomfjikakokcbkjlfgodhklifiplmpg/images/wp-logo.png)]] have you checked why unit tests are failed?
looks like I just needed to update the wp-api fixtures which i did in 57c4f00 (by running the test_build_wp_api_client_fixtures test locally)
Add preloaded paths for the client-side media processing feature. These settings are needed by the editor to perform client-side image resizing, thumbnail generation, and format conversion.
The following site settings are now preloaded in both the post editor and site editor:
image_sizes- Available image size configurationsimage_size_threshold- Big image size threshold (default 2560px)image_output_formats- Output format mappings for image conversionjpeg_interlaced- Whether to use progressive/interlaced JPEG encodingpng_interlaced- Whether to use interlaced PNG encodinggif_interlaced- Whether to use interlaced GIF encodingGutenberg PRs:
Gutenberg tracking issue: https://github.com/WordPress/gutenberg/issues/75062
Trac ticket: https://core.trac.wordpress.org/ticket/64597