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/wpGetImageMime.php tests/phpunit/tests/functions/wpGetImageMime.php
new file mode 100644
index 0000000..dcb4b63
|
-
|
+
|
|
| | 1 | <?php |
| | 2 | |
| | 3 | /** |
| | 4 | * Tests for wp_get_image_mime() |
| | 5 | * |
| | 6 | * @group functions.php |
| | 7 | * @ticket 40017 |
| | 8 | */ |
| | 9 | class Tests_Functions_Wp_Get_Image_Mime extends WP_UnitTestCase { |
| | 10 | function setUp() { |
| | 11 | if ( ! is_callable( 'exif_imagetype' ) && ! function_exists( 'getimagesize' ) ) |
| | 12 | $this->markTestSkipped( 'The exif PHP extension is not loaded.' ); |
| | 13 | parent::setUp(); |
| | 14 | } |
| | 15 | |
| | 16 | public function test_wp_get_image_mime() { |
| | 17 | // Test a valid image. |
| | 18 | $out = wp_get_image_mime( DIR_TESTDATA.'/images/2004-07-22-DSC_0008.jpg' ); |
| | 19 | $this->assertEquals( 'image/jpeg', $out ); |
| | 20 | |
| | 21 | // Test a non-image file. |
| | 22 | $out = wp_get_image_mime( DIR_TESTDATA.'/uploads/dashicons.woff' ); |
| | 23 | $this->assertEquals( false, $out ); |
| | 24 | } |
| | 25 | } |