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..50ea235 100644
|
|
|
class Tests_Functions extends WP_UnitTestCase {
|
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | /** |
| | 919 | * @ticket 40017 |
| | 920 | */ |
| | 921 | public function test_wp_get_image_mime() { |
| | 922 | if ( ! is_callable( 'exif_imagetype' ) && ! function_exists( 'getimagesize' ) ) { |
| | 923 | $this->markTestSkipped( 'The exif PHP extension is not loaded.' ); |
| | 924 | } |
| | 925 | |
| | 926 | // Test a valid image. |
| | 927 | $out = wp_get_image_mime( DIR_TESTDATA.'/images/2004-07-22-DSC_0008.jpg' ); |
| | 928 | $this->assertEquals( 'image/jpeg', $out ); |
| | 929 | |
| | 930 | // Test a non-image file. |
| | 931 | $out = wp_get_image_mime( DIR_TESTDATA.'/uploads/dashicons.woff' ); |
| | 932 | $this->assertEquals( false, $out ); |
| | 933 | } |
| | 934 | |
| | 935 | /** |
| 919 | 936 | * @ticket 39550 |
| 920 | 937 | * @dataProvider _wp_check_filetype_and_ext_data |
| 921 | 938 | */ |