Skip to content

Instantly share code, notes, and snippets.

@tjhole
Created April 24, 2014 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjhole/11260285 to your computer and use it in GitHub Desktop.
Save tjhole/11260285 to your computer and use it in GitHub Desktop.
WORDPRESS: Save GPS Meta on Upload
function add_geo_exif($meta,$file,$sourceImageType) {
$exif = @exif_read_data( $file );
if (!empty($exif['GPSLatitude']))
$meta['latitude'] = $exif['GPSLatitude'] ;
if (!empty($exif['GPSLatitudeRef']))
$meta['latitude_ref'] = trim( $exif['GPSLatitudeRef'] );
if (!empty($exif['GPSLongitude']))
$meta['longitude'] = $exif['GPSLongitude'] ;
if (!empty($exif['GPSLongitudeRef']))
$meta['longitude_ref'] = trim( $exif['GPSLongitudeRef'] );
return $meta;
}
add_filter('wp_read_image_metadata', 'add_geo_exif','',3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment