diff --git src/wp-includes/functions.php src/wp-includes/functions.php
index ee214e9..966dcd8 100644
|
|
|
function wp_get_image_mime( $file ) { |
| 2367 | 2367 | */ |
| 2368 | 2368 | try { |
| 2369 | 2369 | if ( is_callable( 'exif_imagetype' ) ) { |
| 2370 | | $mime = image_type_to_mime_type( exif_imagetype( $file ) ); |
| | 2370 | $imagetype = exif_imagetype( $file ); |
| | 2371 | $mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false; |
| 2371 | 2372 | } elseif ( function_exists( 'getimagesize' ) ) { |
| 2372 | 2373 | $imagesize = getimagesize( $file ); |
| 2373 | 2374 | $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false; |
diff --git tests/phpunit/tests/functions.php tests/phpunit/tests/functions.php
index a3aba79..0c997d7 100644
|
|
|
class Tests_Functions extends WP_UnitTestCase { |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | /** |
| | 919 | * @ticket 40017 |
| | 920 | * @dataProvider _wp_get_image_mime |
| | 921 | */ |
| | 922 | public function test_wp_get_image_mime( $file, $expected ) { |
| | 923 | if ( ! is_callable( 'exif_imagetype' ) && ! function_exists( 'getimagesize' ) ) { |
| | 924 | $this->markTestSkipped( 'The exif PHP extension is not loaded.' ); |
| | 925 | } |
| | 926 | |
| | 927 | $this->assertEquals( $expected, wp_get_image_mime( $file ) ); |
| | 928 | } |
| | 929 | |
| | 930 | /** |
| 919 | 931 | * @ticket 39550 |
| 920 | 932 | * @dataProvider _wp_check_filetype_and_ext_data |
| 921 | 933 | */ |
| … |
… |
class Tests_Functions extends WP_UnitTestCase { |
| 993 | 1005 | return $mimes; |
| 994 | 1006 | } |
| 995 | 1007 | |
| | 1008 | public function _wp_get_image_mime() { |
| | 1009 | $data = array( |
| | 1010 | // Standard JPEG. |
| | 1011 | array( |
| | 1012 | DIR_TESTDATA . '/images/test-image.jpg', |
| | 1013 | 'image/jpeg' |
| | 1014 | ), |
| | 1015 | // Standard GIF. |
| | 1016 | array( |
| | 1017 | DIR_TESTDATA . '/images/test-image.gif', |
| | 1018 | 'image/gif' |
| | 1019 | ), |
| | 1020 | // Standard PNG. |
| | 1021 | array( |
| | 1022 | DIR_TESTDATA . '/images/test-image.png', |
| | 1023 | 'image/png' |
| | 1024 | ), |
| | 1025 | // Image with wrong extension. |
| | 1026 | array( |
| | 1027 | DIR_TESTDATA . '/images/test-image-mime-jpg.png', |
| | 1028 | 'image/jpeg' |
| | 1029 | ), |
| | 1030 | // Not an image. |
| | 1031 | array( |
| | 1032 | DIR_TESTDATA.'/uploads/dashicons.woff', |
| | 1033 | false |
| | 1034 | ), |
| | 1035 | ); |
| | 1036 | |
| | 1037 | return $data; |
| | 1038 | } |
| | 1039 | |
| 996 | 1040 | public function _wp_check_filetype_and_ext_data() { |
| 997 | 1041 | $data = array( |
| 998 | 1042 | // Standard image. |