WordPress.org

Make WordPress Core

Ticket #5397: 5397.exif.the-proper-way.diff

File 5397.exif.the-proper-way.diff, 1.7 KB (added by DD32, 10 years ago)
  • wp-admin/includes/image.php

     
    250250        if ( !file_exists( $file ) )
    251251                return false;
    252252
     253        list(,,$sourceImageType) = getimagesize( $file );
     254
    253255        // exif contains a bunch of data we'll probably never need formatted in ways that are difficult to use.
    254256        // We'll normalize it and just extract the fields that are likely to be useful.  Fractions and numbers
    255257        // are converted to floats, dates to unix timestamps, and everything else to strings.
     
    287289        }
    288290
    289291        // fetch additional info from exif if available
    290         if ( is_callable('exif_read_data') ) {
     292        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)) ) ) {
    291293                $exif = exif_read_data( $file );
    292294                if (!empty($exif['FNumber']))
    293295                        $meta['aperture'] = round( wp_exif_frac2dec( $exif['FNumber'] ), 2 );
     
    304306        }
    305307        // FIXME: try other exif libraries if available
    306308
    307         return apply_filters( 'wp_read_image_metadata', $meta, $file );
     309        return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );
    308310
    309311}
    310312
  • wp-includes/compat.php

     
    157157if (!defined('IMAGETYPE_PNG'))
    158158    define('IMAGETYPE_PNG', 3);
    159159
     160if (!defined('IMAGETYPE_TIFF_MM'))
     161        define('IMAGETYPE_TIFF_MM',7);
    160162
     163if (!defined('IMAGETYPE_TIFF_MM'))
     164        define('IMAGETYPE_TIFF_MM',8);
     165
    161166?>