Ensure we don't call exif_read_data() on unsupported file types. Fixes #5397 props DD32
git-svn-id: http://svn.automattic.com/wordpress/trunk@6438 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6950e2833b
commit
71b2207ea3
|
@ -250,6 +250,8 @@ function wp_read_image_metadata( $file ) {
|
||||||
if ( !file_exists( $file ) )
|
if ( !file_exists( $file ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
list(,,$sourceImageType) = getimagesize( $file );
|
||||||
|
|
||||||
// exif contains a bunch of data we'll probably never need formatted in ways that are difficult to use.
|
// exif contains a bunch of data we'll probably never need formatted in ways that are difficult to use.
|
||||||
// We'll normalize it and just extract the fields that are likely to be useful. Fractions and numbers
|
// We'll normalize it and just extract the fields that are likely to be useful. Fractions and numbers
|
||||||
// are converted to floats, dates to unix timestamps, and everything else to strings.
|
// are converted to floats, dates to unix timestamps, and everything else to strings.
|
||||||
|
@ -287,7 +289,7 @@ function wp_read_image_metadata( $file ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fetch additional info from exif if available
|
// fetch additional info from exif if available
|
||||||
if ( is_callable('exif_read_data') ) {
|
if ( is_callable('exif_read_data') && in_array($sourceImageType, apply_filters('wp_read_image_metadata_types', array(IMAGETYPE_JPEG, IMAGETYPE_TIFF_II, IMAGETYPE_TIFF_MM)) ) ) {
|
||||||
$exif = exif_read_data( $file );
|
$exif = exif_read_data( $file );
|
||||||
if (!empty($exif['FNumber']))
|
if (!empty($exif['FNumber']))
|
||||||
$meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
|
$meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
|
||||||
|
@ -304,7 +306,7 @@ function wp_read_image_metadata( $file ) {
|
||||||
}
|
}
|
||||||
// FIXME: try other exif libraries if available
|
// FIXME: try other exif libraries if available
|
||||||
|
|
||||||
return apply_filters( 'wp_read_image_metadata', $meta, $file );
|
return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -178,5 +178,10 @@ if (!defined('IMAGETYPE_JPEG'))
|
||||||
if (!defined('IMAGETYPE_PNG'))
|
if (!defined('IMAGETYPE_PNG'))
|
||||||
define('IMAGETYPE_PNG', 3);
|
define('IMAGETYPE_PNG', 3);
|
||||||
|
|
||||||
|
if (!defined('IMAGETYPE_TIFF_MM'))
|
||||||
|
define('IMAGETYPE_TIFF_MM',7);
|
||||||
|
|
||||||
|
if (!defined('IMAGETYPE_TIFF_MM'))
|
||||||
|
define('IMAGETYPE_TIFF_MM',8);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue