Update Jan 2015: Unfortunately the filter used to add extra meta to Jetpack was removed from the Jetpack plugin in Feb 2014, so until the filter is added back in there is no simple way to do this anymore.
I received a good question regarding Exifography in the WordPress support forums: can you add location to Jetpack carousel?
It looks like Jetpack will eventually be adding location data to the carousel view. They have it all built in, but the notes in the source code say they want to “fuzzify” the data for privacy before letting you display it (also, they don’t seem to have built in a way to import location data for photos). I’m not quite sure how they will fuzzify data and still provide useful location information, perhaps it will just reduce the number of decimal points in the location. Anyway, if you don’t want to wait for that to happen you can use the following filter in your theme’s functions.php (or custom_functions.php in Thesis) to show a nice little map in your Jetpack Carousel.
function add_geo_meta_carousel($html,$imgID) {
$allmeta = wp_get_attachment_metadata($imgID);
$imgmeta = $allmeta['image_meta'];
if (class_exists('exifography')) {
$exif = new exifography();
if (isset($imgmeta['latitude'])) {
if ($imgmeta['latitude'])
$latitude = $imgmeta['latitude'];
if ($imgmeta['longitude'])
$longitude = $imgmeta['longitude'];
if ($imgmeta['latitude_ref'])
$lat_ref = $imgmeta['latitude_ref'];
if ($imgmeta['longitude_ref'])
$lng_ref = $imgmeta['longitude_ref'];
$lat = $exif->geo_single_fracs2dec($latitude);
$lng = $exif->geo_single_fracs2dec($longitude);
if ($lat_ref == 'S') { $neg_lat = '-'; } else { $neg_lat = ''; }
if ($lng_ref == 'W') { $neg_lng = '-'; } else { $neg_lng = ''; }
$imgmeta['latitude'] = $neg_lat . number_format($lat,6);
$imgmeta['longitude'] = $neg_lng . number_format($lng, 6);
//remove raw geo
unset($imgmeta['latitude_ref']);
unset($imgmeta['longitude_ref']);
$imgmeta = json_encode($imgmeta);
$html = preg_replace('/data-image-meta="\{.*?\}"/',
'data-image-meta="'.esc_attr($imgmeta).'"',
$html);
}
}
return $html;
}
add_filter('jp_carousel_add_data_to_images','add_geo_meta_carousel',10,2);
You do need to have the Exifography plugin installed and active in order to enable import of location data when uploading images and to use the fractions to decimal functions that are in this filter.
sovo says
Nice tutorial. thank you for this tutorial