Media: Add an opt-in filter to generate animated image sub-sizes#12572
Media: Add an opt-in filter to generate animated image sub-sizes#12572adamsilverstein wants to merge 2 commits into
Conversation
… index. Sub-sizes of animated images are static first-frame images by default because re-encoding every frame per sub-size is very resource intensive. The client-side media processing path can preserve animation in the browser, so expose an opt-in flag on the REST API index (alongside image_size_threshold) that the client pipeline honors for uncropped sub-sizes. See WordPress/gutenberg#80383 and WordPress/gutenberg#80385.
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. |
|
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. |
| $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); | ||
| $this->assertIsInt( $user_id ); | ||
| wp_set_current_user( $user_id ); |
There was a problem hiding this comment.
| $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); | |
| $this->assertIsInt( $user_id ); | |
| wp_set_current_user( $user_id ); | |
| wp_set_current_user( self::$admin_id ); |
Reuse admin that already created in wpSetUpBeforeClass
Core backport of the server-side changes in WordPress/gutenberg#80385 (design discussion in WordPress/gutenberg#80383).
Resized versions of animated GIFs have always lost their animation - the subject of the 12-year-old Trac #28474, which stalled server-side because GD cannot preserve frames and Imagick is only available on a subset of hosts. The client-side media processing path can decode and re-encode every frame in the uploading user's browser, independent of host configuration, making animation-preserving sub-sizes feasible as a developer opt-in (they remain too expensive to be the default).
This adds the new
wp_generate_animated_image_subsizesfilter (boolean, defaultfalse) and exposes its value on the REST API index asanimated_image_subsizes, inside the existing client-side media processing block inWP_REST_Server::get_index()(alongsideimage_size_threshold, only for users who canupload_files). When a site opts in, the client pipeline keeps the animation in uncropped sub-sizes of animated GIFs; cropped sizes such asthumbnailalways flatten to the first frame.The field is also added to the block editor root-index preload field lists in
wp-admin/edit-form-blocks.phpandwp-admin/site-editor.php- these must matchpackages/core-data/src/entities.jsexactly for preloading to work, and the matching entities.js change is part of the Gutenberg PR. (Note: #12508 may want to do the same forimage_strip_meta/image_max_bit_depth.)The client-side consumption (editor settings plumbing,
@wordpress/upload-media, and the@wordpress/vipsworker restoring the all-frames load path with tuned GIF encoder settings) ships via the Gutenberg package updates in WordPress/gutenberg#80385.Trac ticket: https://core.trac.wordpress.org/ticket/65656
Proposed commit message