WordPress.org

Ready to get started?Download WordPress

Forums

saving longitude and latitude etc... (1 post)

  1. jynk
    Member
    Posted 3 years ago #

    i've been following this post which tells you how to get add more meta data from your images' exif data.

    I'm trying to add longitude and lat - the below nearly works and adds the metadata fields into the table _postmeta but the values are empty.

    i'm not sure how to express the $file variable in add_filter('wp_read_image_metadata', 'add_geo_exif' );
    the post says to use
    add_filter('wp_read_image_metadata', 'add_geo_exif', , 3); but that doesn't work?

    (placed in the templates' functions.php)

    add_geo_exif($meta,$file,$sourceImageType) {
    	list(,,$sourceImageType) = getimagesize( $file );
    		$exif = exif_read_data( $file );
    			$meta['latitude'] = $exif['GPSLatitude'] ;
    			$meta['latitude_ref'] = trim( $exif['GPSLatitudeRef'] );
    			$meta['longitude'] = $exif['GPSLongitude'] ;
    			$meta['longitude_ref'] = trim( $exif['GPSLongitudeRef'] );
    
    	return $meta;
    }
    add_filter('wp_read_image_metadata', 'add_geo_exif');

    any help much appreciated!

Topic Closed

This topic has been closed to new replies.

About this Topic