From efab6e06cae3ed14c6b681570dfd5f81917d9f9c Mon Sep 17 00:00:00 2001 From: Joe McGill Date: Sun, 9 Apr 2017 22:44:43 +0000 Subject: [PATCH] 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 --- wp-includes/functions.php | 3 ++- wp-includes/version.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index ee214e923a..966dcd8265 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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; diff --git a/wp-includes/version.php b/wp-includes/version.php index ef08be26d0..56f4995688 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.