- Timestamp:
- 04/09/2017 10:43:04 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r40124 r40397 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 ); -
trunk/tests/phpunit/tests/functions.php
r40125 r40397 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 … … 992 1004 $mimes['woff'] = 'application/font-woff'; 993 1005 return $mimes; 1006 } 1007 1008 /** 1009 * Data profider for test_wp_get_image_mime(); 1010 */ 1011 public function _wp_get_image_mime() { 1012 $data = array( 1013 // Standard JPEG. 1014 array( 1015 DIR_TESTDATA . '/images/test-image.jpg', 1016 'image/jpeg', 1017 ), 1018 // Standard GIF. 1019 array( 1020 DIR_TESTDATA . '/images/test-image.gif', 1021 'image/gif', 1022 ), 1023 // Standard PNG. 1024 array( 1025 DIR_TESTDATA . '/images/test-image.png', 1026 'image/png', 1027 ), 1028 // Image with wrong extension. 1029 array( 1030 DIR_TESTDATA . '/images/test-image-mime-jpg.png', 1031 'image/jpeg', 1032 ), 1033 // Not an image. 1034 array( 1035 DIR_TESTDATA . '/uploads/dashicons.woff', 1036 false, 1037 ), 1038 ); 1039 1040 return $data; 994 1041 } 995 1042
Note: See TracChangeset
for help on using the changeset viewer.