diff --git src/wp-includes/class-wp-image-editor.php src/wp-includes/class-wp-image-editor.php
index 7dcdc91d5a..adad9e1f91 100644
|
|
|
abstract class WP_Image_Editor { |
| 316 | 316 | $new_ext = $file_ext; |
| 317 | 317 | } |
| 318 | 318 | |
| | 319 | /** |
| | 320 | * Filters the image editor output format. |
| | 321 | * |
| | 322 | * Enables filtering the mime type used to save images. By default, |
| | 323 | * the mime type matches the source image. |
| | 324 | * |
| | 325 | * @see src/wp-includes/class-wp-image-editor.php -> get_output_format() |
| | 326 | * |
| | 327 | * @since 5.8.0 |
| | 328 | * |
| | 329 | * @param array $wp_image_editor_output_format { |
| | 330 | * An array of mime type mappings. Maps a source mime type to a new |
| | 331 | * destination mime type. Empty by default. |
| | 332 | * |
| | 333 | * @type array $mime_type The source mime type { |
| | 334 | * @type string $mime_type The new mime type. |
| | 335 | * } |
| | 336 | * @param string $mime_type The source image mime type. |
| | 337 | * } |
| | 338 | */ |
| | 339 | $wp_image_editor_output_format = apply_filters( 'image_editor_output_format', array(), $mime_type ); |
| | 340 | |
| | 341 | if ( |
| | 342 | isset( $wp_image_editor_output_format[ $mime_type ] ) && |
| | 343 | $this->supports_mime_type( $wp_image_editor_output_format[ $mime_type ] ) |
| | 344 | ) { |
| | 345 | $mime_type = $wp_image_editor_output_format[ $mime_type ]; |
| | 346 | $new_ext = $this->get_extension( $mime_type ); |
| | 347 | } |
| | 348 | |
| 319 | 349 | // Double-check that the mime-type selected is supported by the editor. |
| 320 | 350 | // If not, choose a default instead. |
| 321 | 351 | if ( ! $this->supports_mime_type( $mime_type ) ) { |
diff --git src/wp-includes/media.php src/wp-includes/media.php
index 82d1b32627..6008c69254 100644
|
|
|
function _wp_image_editor_choose( $args = array() ) { |
| 3749 | 3749 | continue; |
| 3750 | 3750 | } |
| 3751 | 3751 | |
| 3752 | | if ( isset( $args['mime_type'] ) && |
| 3753 | | ! call_user_func( |
| 3754 | | array( $implementation, 'supports_mime_type' ), |
| 3755 | | $args['mime_type'] |
| 3756 | | ) ) { |
| 3757 | | continue; |
| | 3752 | if ( isset( $args['mime_type'] ) { |
| | 3753 | |
| | 3754 | /* This filter is documented in src/wp-includes/media.php */ |
| | 3755 | $wp_image_editor_output_format = apply_filters( 'image_editor_output_format', array(), $args['mime_type'] ); |
| | 3756 | |
| | 3757 | if ( |
| | 3758 | isset( $wp_image_editor_output_format[ $args['mime_type'] ) && |
| | 3759 | ! call_user_func( |
| | 3760 | array( $implementation, 'supports_mime_type' ), |
| | 3761 | $wp_image_editor_output_format[ $args['mime_type'] ) |
| | 3762 | ) ) { |
| | 3763 | continue; |
| | 3764 | } |
| | 3765 | |
| | 3766 | if ( ! call_user_func( |
| | 3767 | array( $implementation, 'supports_mime_type' ), |
| | 3768 | $args['mime_type'] |
| | 3769 | ) ) { |
| | 3770 | continue; |
| | 3771 | } |
| 3758 | 3772 | } |
| 3759 | 3773 | |
| 3760 | 3774 | if ( isset( $args['methods'] ) && |