Make WordPress Core

Changeset 64490


Ignore:
Timestamp:
10/18/2026 10:36:44 PM (30 hours ago)
Author:
adamsilverstein
Message:

Media: Generate animated image sub-sizes by default.

Fix an issue where sub-sizes of animated image uploads were static first-frame images, as GD and Imagick flatten animated images when resizing. When client-side media processing is active, generated images now retain animations.

Add a wp_generate_animated_image_subsizes filter (boolean, default true) so the client pipeline can keep or drop the animation in sub-sizes. The client-side consumption ships via the Gutenberg package updates in ​https://github.com/WordPress/gutenberg/pull/80385.

Fixes #65656, #28474.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-blocks.php

    r64120 r64490  
    9595                array(
    9696                        'description',
     97                        'generate_animated_image_subsizes',
    9798                        'gmt_offset',
    9899                        'home',
  • trunk/src/wp-admin/site-editor.php

    r62846 r64490  
    221221                array(
    222222                        'description',
     223                        'generate_animated_image_subsizes',
    223224                        'gmt_offset',
    224225                        'home',
  • trunk/src/wp-includes/rest-api/class-wp-rest-server.php

    r63780 r64490  
    14641464                        /** This filter is documented in wp-includes/class-wp-image-editor-imagick.php */
    14651465                        $available['image_max_bit_depth'] = (int) apply_filters( 'image_max_bit_depth', 16, 16 );
     1466
     1467                        /**
     1468                         * Filters whether client-side media processing preserves animation in image sub-sizes.
     1469                         *
     1470                         * By default, sub-sizes of animated GIF and WebP images retain animation,
     1471                         * including cropped sizes. Return false to generate static sub-sizes using
     1472                         * only the first frame, reducing processing time in the browser.
     1473                         *
     1474                         * This setting applies only to client-side media processing. Server-side
     1475                         * processing continues to generate static sub-sizes.
     1476                         *
     1477                         * @since 7.2.0
     1478                         *
     1479                         * @param bool $generate_animated_image_subsizes Whether to preserve animation in image sub-sizes.
     1480                         *                                               Default true.
     1481                         */
     1482                        $available['generate_animated_image_subsizes'] = (bool) apply_filters( 'wp_generate_animated_image_subsizes', true );
    14661483                }
    14671484
  • trunk/tests/phpunit/tests/rest-api/rest-server.php

    r64074 r64490  
    12151215        /**
    12161216         * @ticket 64804
     1217         * @ticket 65656
    12171218         *
    12181219         * @covers WP_REST_Server::get_index
    … …  
    12351236                $this->assertArrayHasKey( 'image_max_bit_depth', $data );
    12361237                $this->assertSame( 16, $data['image_max_bit_depth'] );
     1238                $this->assertArrayHasKey( 'generate_animated_image_subsizes', $data );
     1239                $this->assertTrue( $data['generate_animated_image_subsizes'] );
    12371240        }
    12381241
    12391242        /**
    12401243         * @ticket 64804
     1244         * @ticket 65656
    12411245         *
    12421246         * @covers WP_REST_Server::get_index
    … …  
    12551259                $this->assertArrayNotHasKey( 'image_strip_meta', $data );
    12561260                $this->assertArrayNotHasKey( 'image_max_bit_depth', $data );
     1261                $this->assertArrayNotHasKey( 'generate_animated_image_subsizes', $data );
    12571262        }
    12581263
    12591264        /**
    12601265         * @ticket 64804
     1266         * @ticket 65656
    12611267         *
    12621268         * @covers WP_REST_Server::get_index
    … …  
    12711277                        static fn ( int $max_depth ) => min( 8, $max_depth )
    12721278                );
     1279                add_filter( 'wp_generate_animated_image_subsizes', '__return_false' );
    12731280
    12741281                $server  = new WP_REST_Server();
    … …  
    12791286                $this->assertFalse( $data['image_strip_meta'] );
    12801287                $this->assertSame( 8, $data['image_max_bit_depth'] );
     1288                $this->assertFalse( $data['generate_animated_image_subsizes'] );
    12811289        }
    12821290
  • trunk/tests/qunit/fixtures/wp-api-generated.js

    r64311 r64490  
    1307913079    "image_strip_meta": true,
    1308013080    "image_max_bit_depth": 16,
     13081    "generate_animated_image_subsizes": true,
    1308113082    "site_logo": 0,
    1308213083    "site_icon": 0,
Note: See TracChangeset for help on using the changeset viewer.