Make WordPress Core

Ticket #21668: 21668.diff

File 21668.diff, 2.3 KB (added by adamsilverstein, 13 months ago)
  • src/wp-includes/class-wp-image-editor-gd.php

    diff --git src/wp-includes/class-wp-image-editor-gd.php src/wp-includes/class-wp-image-editor-gd.php
    index de079357fb..b7424f29df 100644
    class WP_Image_Editor_GD extends WP_Image_Editor { 
    491491                if ( ! $filename ) {
    492492                        $filename = $this->generate_filename( null, null, $extension );
    493493                }
     494                if ( function_exists( 'imageinterlace' ) ) {
     495                        /** This filter is documented in wp-includes/class-wp-image-editor-imagick.php */
     496                        imageinterlace( $image, apply_filters( 'image_save_progressive', false, $mime_type ) );
     497                }
    494498
    495499                if ( 'image/gif' === $mime_type ) {
    496500                        if ( ! $this->make_image( $filename, 'imagegif', array( $image, $filename ) ) ) {
  • src/wp-includes/class-wp-image-editor-imagick.php

    diff --git src/wp-includes/class-wp-image-editor-imagick.php src/wp-includes/class-wp-image-editor-imagick.php
    index 03fe0bca69..281b838b4c 100644
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    478478                                        $this->image->setImageDepth( 8 );
    479479                                }
    480480                        }
    481 
    482                         if ( is_callable( array( $this->image, 'setInterlaceScheme' ) ) && defined( 'Imagick::INTERLACE_NO' ) ) {
    483                                 $this->image->setInterlaceScheme( Imagick::INTERLACE_NO );
    484                         }
    485481                } catch ( Exception $e ) {
    486482                        return new WP_Error( 'image_resize_error', $e->getMessage() );
    487483                }
    class WP_Image_Editor_Imagick extends WP_Image_Editor { 
    814810                        return new WP_Error( 'image_save_error', $e->getMessage(), $filename );
    815811                }
    816812
     813                if ( method_exists( $this->image, 'setInterlaceScheme' ) && defined( 'Imagick::INTERLACE_PLANE' ) ) {
     814                        /**
     815                         * Filters whether to use output interlaced (progressive) images.
     816                         *
     817                         * @since 6.5.0
     818                         *
     819                         * @param bool   $interlace Whether to use interlaced images. Default false.
     820                         * @param string $mime_type The mime type being saved.
     821                         */
     822                        if( apply_filters( 'image_save_progressive', false, $mime_type ) ) {
     823                                $this->image->setInterlaceScheme( Imagick::INTERLACE_NONE );
     824                        } else {
     825                                $this->image->setInterlaceScheme( Imagick::INTERLACE_PLANE );
     826                }
     827
    817828                $write_image_result = $this->write_image( $this->image, $filename );
    818829                if ( is_wp_error( $write_image_result ) ) {
    819830                        return $write_image_result;