Media: Improve handling of non-image files in wp_get_image_mime.

This prevents non-image fileypes from returning a mime type of
"application/octet-stream" when `exif_imagetype()` returns `false`.

Props blobfolio.
Fixes #40017.

Built from https://develop.svn.wordpress.org/trunk@40397


git-svn-id: http://core.svn.wordpress.org/trunk@40304 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Joe McGill 2017-04-09 22:44:43 +00:00
parent 57b386ef1e
commit efab6e06ca
2 changed files with 3 additions and 2 deletions

View File

@ -2367,7 +2367,8 @@ function wp_get_image_mime( $file ) {
*/
try {
if ( is_callable( 'exif_imagetype' ) ) {
$mime = image_type_to_mime_type( exif_imagetype( $file ) );
$imagetype = exif_imagetype( $file );
$mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false;
} elseif ( function_exists( 'getimagesize' ) ) {
$imagesize = getimagesize( $file );
$mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40396';
$wp_version = '4.8-alpha-40397';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.