diff --git src/wp-includes/media.php src/wp-includes/media.php
index 51c49f83d2..4d38fa6b48 100644
|
|
function wp_get_image_editor( $path, $args = array() ) { |
3942 | 3942 | } |
3943 | 3943 | } |
3944 | 3944 | |
| 3945 | $mime_type = isset( $args['mime_type'] ) ? $args['mime_type'] : wp_check_filetype( $path )['type']; |
| 3946 | |
| 3947 | /** This filter is documented in wp-includes/class-wp-image-editor.php */ |
| 3948 | $output_format = apply_filters( 'image_editor_output_format', array(), $path, $mime_type ); |
| 3949 | if ( isset( $output_format[ $mime_type ] ) ) { |
| 3950 | $args['output_mime_type'] = $output_format[ $mime_type ]; |
| 3951 | } |
| 3952 | |
3945 | 3953 | $implementation = _wp_image_editor_choose( $args ); |
3946 | 3954 | |
3947 | 3955 | if ( $implementation ) { |
… |
… |
function _wp_image_editor_choose( $args = array() ) { |
4000 | 4008 | continue; |
4001 | 4009 | } |
4002 | 4010 | |
| 4011 | // Implementation should support the passed mime type. |
4003 | 4012 | if ( isset( $args['mime_type'] ) && |
4004 | 4013 | ! call_user_func( |
4005 | 4014 | array( $implementation, 'supports_mime_type' ), |
… |
… |
function _wp_image_editor_choose( $args = array() ) { |
4008 | 4017 | continue; |
4009 | 4018 | } |
4010 | 4019 | |
| 4020 | // Implementation should support the output mime type as well if set and different than the passed type. |
| 4021 | if ( |
| 4022 | isset( $args['mime_type'] ) && |
| 4023 | isset( $args['output_mime_type'] ) && |
| 4024 | $args['mime_type'] !== $args['output_mime_type'] && |
| 4025 | ! call_user_func( array( $implementation, 'supports_mime_type' ), $args['output_mime_type'] ) |
| 4026 | ) { |
| 4027 | continue; |
| 4028 | } |
| 4029 | |
| 4030 | // Implementation should support requested methods. |
4011 | 4031 | if ( isset( $args['methods'] ) && |
4012 | 4032 | array_diff( $args['methods'], get_class_methods( $implementation ) ) ) { |
4013 | 4033 | |
diff --git tests/phpunit/tests/image/editor.php tests/phpunit/tests/image/editor.php
index c051ffec2b..9d0f674d2d 100644
|
|
class Tests_Image_Editor extends WP_Image_UnitTestCase { |
126 | 126 | $this->assertSame( 82, $editor->get_quality(), 'Default quality setting is 82.' ); |
127 | 127 | |
128 | 128 | // 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. |
130 | 130 | $editor->save(); |
131 | 131 | $this->assertSame( 86, $editor->get_quality(), 'Output image format is WEBP. Quality setting for it should be 86.' ); |
132 | 132 | |