Make WordPress Core

Ticket #54476: 54476.2.diff

File 54476.2.diff, 1.9 KB (added by adamsilverstein, 3 years ago)
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index 2b46167afc..97153638ef 100644
    function wp_get_image_editor( $path, $args = array() ) { 
    37753775                }
    37763776        }
    37773777
     3778        /** This filter is documented in wp-includes/class-wp-image-editor.php */
     3779        $output_format = apply_filters( 'image_editor_output_format', array(), $path, $args['mime_type'] );
     3780        if ( isset( $output_format[ $args['mime_type'] ] ) ) {
     3781                $args['output_mime_type'] = $output_format[ $args['mime_type'] ];
     3782        }
     3783
    37783784        $implementation = _wp_image_editor_choose( $args );
    37793785
    37803786        if ( $implementation ) {
    function _wp_image_editor_choose( $args = array() ) { 
    38333839                        continue;
    38343840                }
    38353841
     3842                // If both mime type and output type are set, implementation should support both.
     3843                if (
     3844                        isset( $args['mime_type'] ) &&
     3845                        isset( $args['output_mime_type'] ) &&
     3846                        (
     3847                                ! call_user_func( array( $implementation, 'supports_mime_type' ), $args['output_mime_type'] ) ||
     3848                                ! call_user_func( array( $implementation, 'supports_mime_type' ), $args['mime_type'] )
     3849                        )
     3850                ) {
     3851                        continue;
     3852                }
     3853
    38363854                if ( isset( $args['mime_type'] ) &&
    38373855                        ! call_user_func(
    38383856                                array( $implementation, 'supports_mime_type' ),
  • tests/phpunit/tests/image/editor.php

    diff --git tests/phpunit/tests/image/editor.php tests/phpunit/tests/image/editor.php
    index 487dad0664..95981bad82 100644
    class Tests_Image_Editor extends WP_Image_UnitTestCase { 
    126126                $this->assertSame( 82, $editor->get_quality(), 'Default quality setting is 82.' );
    127127
    128128                // Quality should change to the output format's value.
    129                 // A PNG image will be converted to WEBP whose quialty should be 86.
     129                // A PNG image will be converted to WEBP whose quality should be 86.
    130130                $editor->save();
    131131                $this->assertSame( 86, $editor->get_quality(), 'Output image format is WEBP. Quality setting for it should be 86.' );
    132132