Hi,
I've been at this on and off for months and have searched extensively without finding the answer.
I would like to filter the function wp_read_image_metadata (in wp-admin/includes/image.php) to add latitude and longitude values to the image meta in the database. I have been able to achieve this in the past by editing the file directly (as per http://www.kristarella.com/2008/12/geo-exif-data-in-wordpress/). However I would like to put it in a plugin or theme functions file to avoid having to edit the file every WP update.
So far I have:
function add_geo_exif($meta,$file,$sourceImageType) {
list(,,$sourceImageType) = getimagesize( $file );
$exif = exif_read_data( $file );
$meta['latitude'] = $exif['GPSLatitude'] ;
$meta['latitude_ref'] = trim( $exif['GPSLatitudeRef'] );
$meta['longitude'] = $exif['GPSLongitude'] ;
$meta['longitude_ref'] = trim( $exif['GPSLongitudeRef'] );
return $meta;
}
add_filter('wp_read_image_metadata', 'add_geo_exif');
That code successfully filters the function and adds those fields to the database, but the values are empty. I think it's because my function doesn't know what $file is, but I can't figure out what I need to add to define $file.
Appreciate any insight anyone can provide into this. Thanks!