Make WordPress Core

Ticket #39387: miqro-39387.diff

File miqro-39387.diff, 1.3 KB (added by miqrogroove, 7 years ago)

Add filter for GIF image handling.

  • src/wp-includes/media.php

     
    10691069
    10701070        $image_basename = wp_basename( $image_meta['file'] );
    10711071
     1072        /**
     1073         * Filters the on/off behavior of responsive images when a GIF is used.
     1074         *
     1075         * @since 4.8.0
     1076         *
     1077         * @param bool $make_gifs_responsive Set this to true if you want all GIF images to have responsive srcset.
     1078         */
     1079        $make_gifs_responsive = apply_filters( 'wp_calculate_image_srcset_gif', false );
     1080
    10721081        /*
    10731082         * WordPress flattens animated GIFs into one frame when generating intermediate sizes.
    10741083         * To avoid hiding animation in user content, if src is a full size GIF, a srcset attribute is not generated.
    10751084         * If src is an intermediate size GIF, the full size is excluded from srcset to keep a flattened GIF from becoming animated.
    10761085         */
    1077         if ( ! isset( $image_sizes['thumbnail']['mime-type'] ) || 'image/gif' !== $image_sizes['thumbnail']['mime-type'] ) {
     1086        if ( $make_gifs_responsive || ! isset( $image_sizes['thumbnail']['mime-type'] ) || 'image/gif' !== $image_sizes['thumbnail']['mime-type'] ) {
    10781087                $image_sizes[] = array(
    10791088                        'width'  => $image_meta['width'],
    10801089                        'height' => $image_meta['height'],