Make WordPress Core

Ticket #9257: 9257.patch

File 9257.patch, 1.7 KB (added by Viper007Bond, 14 years ago)

Patch version of previous attachment

  • wp-admin/includes/image.php

     
    213213}
    214214
    215215/**
     216 * Convert the exif geo longitude and latitude format from degrees, minutes and
     217 * seconds to a float degrees.
     218 *
     219 * @since 2.7.0
     220 *
     221 * @param string $geo
     222 * @return float
     223 */
     224function wp_exif_gpsconvert($geo) {
     225        @list( $degree, $minute, $second ) = $geo;
     226        $float = wp_exif_frac2dec($degree)  + (wp_exif_frac2dec($minute)/60) + (wp_exif_frac2dec($second)/3600);
     227       
     228        return is_float($float) ? $float : 999;
     229}
     230
     231/**
    216232 * Get extended image metadata, exif or iptc as available.
    217233 *
    218234 * Retrieves the EXIF metadata aperture, credit, camera, caption, copyright, iso
     
    249265                'iso' => 0,
    250266                'shutter_speed' => 0,
    251267                'title' => '',
     268                'gps_longitude' => 999,
     269                'gps_latitude' => 999,
    252270        );
    253271
    254272        // read iptc first, since it might contain data not available in exif such
     
    287305                        $meta['iso'] = $exif['ISOSpeedRatings'];
    288306                if (!empty($exif['ExposureTime']))
    289307                        $meta['shutter_speed'] = wp_exif_frac2dec( $exif['ExposureTime'] );
     308                if (!empty($exif['GPSLongitude']) && count($exif['GPSLongitude']) == 3 && !empty($exif['GPSLongitudeRef']))
     309                        $meta['gps_longitude'] = ($exif['GPSLongitudeRef']== 'W' ? '-' : '') . wp_exif_gpsconvert( $exif['GPSLongitude'] );
     310                if (!empty($exif['GPSLatitude']) && count($exif['GPSLatitude']) == 3 && !empty($exif['GPSLatitudeRef']))
     311                        $meta['gps_latitude'] = ($exif['GPSLatitudeRef']== 'S' ? '-' : '') . wp_exif_gpsconvert( $exif['GPSLatitude'] );
    290312        }
    291313
    292314        return apply_filters( 'wp_read_image_metadata', $meta, $file, $sourceImageType );