Ticket #39552: functions.php.2.patch
File functions.php.2.patch, 1.3 KB (added by , 8 years ago) |
---|
-
wp-includes/functions.php
2366 2366 */ 2367 2367 try { 2368 2368 if ( is_callable( 'exif_imagetype' ) ) { 2369 $mime = image_type_to_mime_type( exif_imagetype( $file ) ); 2369 $imagetype = exif_imagetype( $file ); 2370 // avoid falling back to application/octet-stream when exif_imagetype returns false 2371 if( $imagetype !== false ) { 2372 $mime = image_type_to_mime_type( $imagetype ); 2373 } else { 2374 $mime = false; 2375 } 2370 2376 } elseif ( function_exists( 'getimagesize' ) ) { 2371 2377 $imagesize = getimagesize( $file ); 2372 2378 $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false; … … 2373 2379 } else { 2374 2380 $mime = false; 2375 2381 } 2382 if( $mime === false && function_exists ( 'finfo_file' ) ){ 2383 /* if the mime type is false we might have an image file not supported by PHP Constants (this applies 2384 * at least to svg, but might apply to other file types) To fix this, use finfo to determine the mimetype * instead 2385 */ 2386 $finfo = finfo_open( FILEINFO_MIME_TYPE ); 2387 $mime = finfo_file( $finfo, $file ); 2388 finfo_close( $finfo ); 2389 } 2376 2390 } catch ( Exception $e ) { 2377 2391 $mime = false; 2378 2392 }