diff --git src/wp-includes/media.php src/wp-includes/media.php
index 2b46167afc..97153638ef 100644
|
|
function wp_get_image_editor( $path, $args = array() ) { |
3775 | 3775 | } |
3776 | 3776 | } |
3777 | 3777 | |
| 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 | |
3778 | 3784 | $implementation = _wp_image_editor_choose( $args ); |
3779 | 3785 | |
3780 | 3786 | if ( $implementation ) { |
… |
… |
function _wp_image_editor_choose( $args = array() ) { |
3833 | 3839 | continue; |
3834 | 3840 | } |
3835 | 3841 | |
| 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 | |
3836 | 3854 | if ( isset( $args['mime_type'] ) && |
3837 | 3855 | ! call_user_func( |
3838 | 3856 | array( $implementation, 'supports_mime_type' ), |
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 { |
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 | |