Skip to content

REST API: Expose image_strip_meta and image_max_bit_depth in the index#12508

Open
adamsilverstein wants to merge 5 commits into
WordPress:trunkfrom
adamsilverstein:add/client-media-strip-meta-bit-depth
Open

REST API: Expose image_strip_meta and image_max_bit_depth in the index#12508
adamsilverstein wants to merge 5 commits into
WordPress:trunkfrom
adamsilverstein:add/client-media-strip-meta-bit-depth

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Jul 13, 2026

Copy link
Copy Markdown
Member

Core backport of the server-side changes in WordPress/gutenberg#80218.

On the client-side media processing path no server-side WP_Image_Editor is instantiated, so the image_strip_meta and image_max_bit_depth filters never influence generated images (see the hooks audit in WordPress/gutenberg#80210 and follow-up WordPress/gutenberg#80216).

This exposes the filtered values of both hooks on the REST API index inside the existing client-side media processing block in WP_REST_Server::get_index() (alongside image_size_threshold), so the client encoder can honor them:

  • image_strip_meta (bool): when a plugin disables stripping, the client keeps all metadata on generated sub-sizes instead of stripping everything except color profiles.
  • image_max_bit_depth (int): caps the bit depth of client-generated images (relevant for 10/12-bit HDR AVIF sub-sizes). Since the server never decodes the image on this path, the filter is applied with 16 as both the value and the current depth; plugins lowering the cap still take effect.

The client-side consumption of these values ships via the Gutenberg package updates (@wordpress/vips, @wordpress/upload-media, editor settings plumbing) in WordPress/gutenberg#80218.

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

On the client-side media processing path no server-side WP_Image_Editor is instantiated, so the `image_strip_meta` and `image_max_bit_depth` filters never influence generated images. Expose their filtered values on the REST API index (alongside `image_size_threshold`) so the client encoder can honor them: metadata stripping can be disabled and the output bit depth capped for client-generated sub-sizes.

Since the server never decodes the image on this path, `image_max_bit_depth` is applied with 16 (the maximum depth the client encoder can produce) as both the value and the current depth, so plugins lowering the cap still take effect.

See WordPress/gutenberg#80216 and WordPress/gutenberg#80218.

See #64804.
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props adamsilverstein, westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

adamsilverstein added a commit to WordPress/gutenberg that referenced this pull request Jul 13, 2026
The REST index changes in lib/media/load.php are backported to Core
in WordPress/wordpress-develop#12508.
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@adamsilverstein adamsilverstein self-assigned this Jul 13, 2026
@adamsilverstein adamsilverstein added bug Gutenberg Sync Pull requests syncing changes from WordPress/Gutenberg. labels Jul 13, 2026
CI regenerates wp-api-generated.js from the live REST index and
fails when it differs from the committed copy. Add the new
image_strip_meta and image_max_bit_depth fields exposed in
WP_REST_Server::get_index().
Comment thread tests/phpunit/tests/rest-api/rest-server.php Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Gutenberg Sync Pull requests syncing changes from WordPress/Gutenberg.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants