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:
westi 2007-12-20 22:18:28 +00:00
parent 6950e2833b
commit 71b2207ea3
2 changed files with 9 additions and 2 deletions

View File

@ -250,6 +250,8 @@ function wp_read_image_metadata( $file ) {
if ( !file_exists( $file ) )
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.
// 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.
@ -287,7 +289,7 @@ function wp_read_image_metadata( $file ) {
}
// 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 );
if (!empty($exif['FNumber']))
$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
return apply_filters( 'wp_read_image_metadata', $meta, $file );
return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );
}

View File

@ -178,5 +178,10 @@ if (!defined('IMAGETYPE_JPEG'))
if (!defined('IMAGETYPE_PNG'))
define('IMAGETYPE_PNG', 3);
if (!defined('IMAGETYPE_TIFF_MM'))
define('IMAGETYPE_TIFF_MM',7);
if (!defined('IMAGETYPE_TIFF_MM'))
define('IMAGETYPE_TIFF_MM',8);
?>