• Skip to primary navigation
  • Skip to main content
  • Skip to footer
  • Home
  • About
  • My Blogs
    • Photoblog
    • Knots
    • WP.com tips
kristarella.com

kristarella.com

Happiness Engineer at Automattic, lover of knitting, crochet, sci-fi and more

  • Presentations
  • Plugins
    • Exifography
  • Contact
You are here: Home / WordPress / Plugins / Exifography / Add location to Jetpack Carousel

Add location to Jetpack Carousel

19 September 2012 by kristarella

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.

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on X (Opens in new window) X
  • Click to share on Pocket (Opens in new window) Pocket

Like this:

Like Loading...

Related

Filed Under: Exifography, Plugins, Tutorials, WordPress Tagged With: PHP

Reader Interactions

Comments

  1. sovo says

    25 September 2012 at 01:01

    Nice tutorial. thank you for this tutorial

A triptych of baubles. These are very satisfying t A triptych of baubles. These are very satisfying to paint ❤️💚💙

#watercolor #watercolour #christmas
I have really enjoyed this Christmassy painting! S I have really enjoyed this Christmassy painting! So glad my friend asked me to make some cards for our church helpers, because it set me on a roll!
#watercolor #watercolour #christmas #christmascards #watercolorcards
Had a great Saturday at the GKR Karate State Title Had a great Saturday at the GKR Karate State Titles! I was a sub for @jamesxuereb.me in the Blue Flame Dragons thanks to his sprained ankle; we won first round and came fourth overall!
I did a bunch of judging and officiating, which was really good.
I didn’t place in my individual events, but had a very fun final round of kumite (sparring).

#gkrkarate #karate
More stamping tonight. Even better than last night More stamping tonight. Even better than last night’s!
Did some stamping this evening. Love it! I wish I’d done some pages in other ink colours before I dismantled the stamps 😂
Had an appointment in the city, so I got to visit Had an appointment in the city, so I got to visit the @legocertifiedstores_anz Wicked display!
#wicked #lego #afol #sydney
A little book I made from Bunnings paint sample ca A little book I made from Bunnings paint sample cards. It’s going to be for mini paintings and collages. Sometimes it’s nice to start with a colour rather than a blank white page!
A little while ago I did some swatching of Daniel A little while ago I did some swatching of Daniel Smith and Schminke Horodam watercolours. So soothing! I love some of the granulating colours!
#watercolours
Follow on Instagram

Footer

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Top Posts & Pages

  • Sistaco Nail Powder Review
    Sistaco Nail Powder Review
  • Home
    Home
  • Bible reading printouts
    Bible reading printouts

Follow Me On…

  • Instagram
  • X
  • GitHub
  • LinkedIn
  • YouTube

Categories

Copyright © 2025 · Kristen Symonds · kristarella.com

%d