Make WordPress Core

Opened 5 weeks ago

Closed 3 weeks ago

Last modified 11 days ago

#64597 closed enhancement (fixed)

Client Site Media: PHP backports from Gutenberg

Reported by: adamsilverstein's profile adamsilverstein Owned by: adamsilverstein's profile adamsilverstein
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

  1. REST API Index (WP_REST_Server::get_index()): Adds media processing configuration fields to the REST API root index response for users with the upload_files capability.
  1. 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 generation
  • image_size_threshold - Big image size threshold (default 2560px) for automatic scaling of large images
  • image_output_formats - Output format mappings for image conversion (e.g., JPEG to WebP)
  • jpeg_interlaced - Whether to use progressive/interlaced JPEG encoding
  • png_interlaced - Whether to use interlaced PNG encoding
  • gif_interlaced - Whether to use interlaced GIF encoding

These preloaded paths prevent additional REST API requests when the editor loads, improving performance.

Related Gutenberg PRs

Tracking Issue

Testing

REST API Index

  1. As an admin user, make a GET request to /wp-json/ (the REST API root)
  2. Verify the response includes image_sizes, image_size_threshold, image_output_formats, jpeg_interlaced, png_interlaced, and gif_interlaced
  3. As a subscriber (without upload_files capability), verify these fields are NOT present

Editor Preloading

  1. Open the post editor or site editor
  2. Check the Network tab in browser DevTools
  3. Look for the preloaded /?_fields=... request
  4. 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

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 configurations
  • image_size_threshold - Big image size threshold (default 2560px)
  • image_output_formats - Output format mappings for image conversion
  • jpeg_interlaced - Whether to use progressive/interlaced JPEG encoding
  • png_interlaced - Whether to use interlaced PNG encoding
  • gif_interlaced - Whether to use interlaced GIF encoding

Gutenberg PRs:

Gutenberg tracking issue: https://github.com/WordPress/gutenberg/issues/75062

Trac ticket: https://core.trac.wordpress.org/ticket/64597

#2 @wildworks
5 weeks ago

  • Keywords gutenberg-merge added

#3 @wildworks
5 weeks ago

  • Milestone changed from Awaiting Review to 7.0

@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.crt file, 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.crt file, 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)

#13 @audrasjb
3 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

Committed in [61703].

#14 @lopo
11 days ago

We are facing some problems with our worker on Yoast SEO with WP 7.0 beta or latest Gutenberg. It seems that the problem is related to the CORS headers changes introduced with this ticket. Is this an expected side-effect?

Note: See TracTickets for help on using tickets.