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. Merges [40397] to the 4.7 branch. Built from https://develop.svn.wordpress.org/branches/4.7@40403 git-svn-id: http://core.svn.wordpress.org/branches/4.7@40310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6736569b43
commit
e249f4aa32
|
@ -2366,7 +2366,8 @@ function wp_get_image_mime( $file ) {
|
||||||
*/
|
*/
|
||||||
try {
|
try {
|
||||||
if ( is_callable( 'exif_imagetype' ) ) {
|
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' ) ) {
|
} elseif ( function_exists( 'getimagesize' ) ) {
|
||||||
$imagesize = getimagesize( $file );
|
$imagesize = getimagesize( $file );
|
||||||
$mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
|
$mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.7.4-alpha-40402';
|
$wp_version = '4.7.4-alpha-40403';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue