Hi Tommy,
I imagine they will finish that function sometime because they have some nice map stuff built in to the carousel. The note says they want to ‘fuzzify’ for privacy, which I guess is fair enough, but I think would probably defeat the point of showing geo data. They should just add an option whether to display it or not.
Anywho, I was able to build a filter that uses some of the code from Exifography to add the location data in the format that the carousel javascript needs it. I wasn’t able to use the main Exifography display function because it’s built to show the geo as one and in degree format, but the carousel’s map display needs the separate values in decimal format.
Use this in your theme’s functions.php
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);