REST API: Expose image_strip_meta and image_max_bit_depth in the index#12508
REST API: Expose image_strip_meta and image_max_bit_depth in the index#12508adamsilverstein wants to merge 5 commits into
Conversation
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.
|
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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
The REST index changes in lib/media/load.php are backported to Core in WordPress/wordpress-develop#12508.
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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().
Core backport of the server-side changes in WordPress/gutenberg#80218.
On the client-side media processing path no server-side
WP_Image_Editoris instantiated, so theimage_strip_metaandimage_max_bit_depthfilters 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()(alongsideimage_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