diff --git src/wp-includes/media.php src/wp-includes/media.php
index 065efde579..b12d8bd7ae 100644
|
|
|
function wp_max_upload_size() {
|
| 3838 | 3838 | function wp_get_image_editor( $path, $args = array() ) { |
| 3839 | 3839 | $args['path'] = $path; |
| 3840 | 3840 | |
| | 3841 | // If the mime type is not set in args, try to extract and set it from the file. |
| 3841 | 3842 | if ( ! isset( $args['mime_type'] ) ) { |
| 3842 | 3843 | $file_info = wp_check_filetype( $args['path'] ); |
| 3843 | 3844 | |
| … |
… |
function wp_get_image_editor( $path, $args = array() ) {
|
| 3848 | 3849 | } |
| 3849 | 3850 | } |
| 3850 | 3851 | |
| | 3852 | // Check and set the output mime type mapped to the input type. |
| | 3853 | if ( isset( $args['mime_type'] ) ) { |
| | 3854 | /** This filter is documented in wp-includes/class-wp-image-editor.php */ |
| | 3855 | $output_format = apply_filters( 'image_editor_output_format', array(), $path, $args['mime_type'] ); |
| | 3856 | if ( isset( $output_format[ $args['mime_type'] ] ) ) { |
| | 3857 | $args['output_mime_type'] = $output_format[ $args['mime_type'] ]; |
| | 3858 | } |
| | 3859 | } |
| | 3860 | |
| 3851 | 3861 | $implementation = _wp_image_editor_choose( $args ); |
| 3852 | 3862 | |
| 3853 | 3863 | if ( $implementation ) { |
| … |
… |
function _wp_image_editor_choose( $args = array() ) {
|
| 3900 | 3910 | * 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD'. |
| 3901 | 3911 | */ |
| 3902 | 3912 | $implementations = apply_filters( 'wp_image_editors', array( 'WP_Image_Editor_Imagick', 'WP_Image_Editor_GD' ) ); |
| | 3913 | $supports_input = false; |
| 3903 | 3914 | |
| 3904 | 3915 | foreach ( $implementations as $implementation ) { |
| 3905 | 3916 | if ( ! call_user_func( array( $implementation, 'test' ), $args ) ) { |
| 3906 | 3917 | continue; |
| 3907 | 3918 | } |
| 3908 | 3919 | |
| | 3920 | // Implementation should support the passed mime type. |
| 3909 | 3921 | if ( isset( $args['mime_type'] ) && |
| 3910 | 3922 | ! call_user_func( |
| 3911 | 3923 | array( $implementation, 'supports_mime_type' ), |
| … |
… |
function _wp_image_editor_choose( $args = array() ) {
|
| 3914 | 3926 | continue; |
| 3915 | 3927 | } |
| 3916 | 3928 | |
| | 3929 | // Implementation should support requested methods. |
| 3917 | 3930 | if ( isset( $args['methods'] ) && |
| 3918 | 3931 | array_diff( $args['methods'], get_class_methods( $implementation ) ) ) { |
| 3919 | 3932 | |
| 3920 | 3933 | continue; |
| 3921 | 3934 | } |
| 3922 | 3935 | |
| | 3936 | // Implementation should ideally support the output mime type as well if set and different than the passed type. |
| | 3937 | if ( |
| | 3938 | isset( $args['mime_type'] ) && |
| | 3939 | isset( $args['output_mime_type'] ) && |
| | 3940 | $args['mime_type'] !== $args['output_mime_type'] && |
| | 3941 | ! call_user_func( array( $implementation, 'supports_mime_type' ), $args['output_mime_type'] ) |
| | 3942 | ) { |
| | 3943 | // This implementation supports the imput type but not the output type. |
| | 3944 | // Keep looking to see if we can find an implementation that supports both. |
| | 3945 | $supports_input = $implementation; |
| | 3946 | continue; |
| | 3947 | } |
| | 3948 | |
| | 3949 | // Favor the implementation that supports both input and output mime types. |
| 3923 | 3950 | return $implementation; |
| 3924 | 3951 | } |
| 3925 | 3952 | |
| 3926 | | return false; |
| | 3953 | return $supports_input; |
| 3927 | 3954 | } |
| 3928 | 3955 | |
| 3929 | 3956 | /** |