WordPress.org

Ready to get started?Download WordPress

Forums

Exifography
[resolved] Image Gallery Carousel (7 posts)

  1. tmiland
    Member
    Posted 1 year ago #

    Hi again,

    is it possible to add the location data to the Image Gallery Carousel?

    Regards,
    Tommy.

    http://wordpress.org/extend/plugins/thesography/

  2. kristarella
    Member
    Plugin Author

    Posted 1 year ago #

    Is that a plugin? Or the one in Jetpack?

    I'm not familiar with it, but if it uses the WordPress gallery shortcode some of that can be filtered. I wrote this about filtering the image title to add EXIF in galleries: http://www.kristarella.com/2012/09/exif-in-wordpress-gallery-image-titles/

  3. tmiland
    Member
    Posted 1 year ago #

    Hi,

    yes it's the one in jetpack. It's not important, but would have been a nice feature. :)

  4. kristarella
    Member
    Plugin Author

    Posted 1 year ago #

    Oh, I see what you mean... the jetpack carousel already has some EXIF data.

    I can't test jetpack on my local server because the 'connect to WordPress.com' thing doesn't work for locally hosted sites...

    I'm looking at the source code for the carousel and it looks like they will soon have an option to display geo data in some way, but it's not active yet. It looks like the output is filterable, so you might be able to add exifography output in there, but it's a bit too late in the evening for me to be able to figure that out right now. If you happen to search for carousel filters and figure it out, let me know, otherwise I'll try to look at it in the next couple of days.

  5. tmiland
    Member
    Posted 1 year ago #

    I believe there is a carousel version without the need to login... Found it: http://wordpress.org/extend/plugins/carousel-without-jetpack/

    That should give you the opportunity to test things out. :)

    Yes, i saw that too, but don't know if/when they are going to finish that function. I haven't found any info about it.

    Tommy

  6. kristarella
    Member
    Plugin Author

    Posted 1 year ago #

    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);
  7. tmiland
    Member
    Posted 1 year ago #

    Hello kristarella! :-)

    Thank you for doing this, i forgot all about this mod, glad to see you got it!

    Regards,
    Tommy. :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic