Skip Navigation

[Resolved] I want to incorporate EXIF informaoion from featured image in the post

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 6 years ago.

Assisted by: Christian Cox.

Author
Posts
#1132648

Tell us what you are trying to do?
Ultimately, I want to create a map displaying links to posts, where the map reference is take from the EXIF location data for the featured image

Is there any documentation that you are following?
I am using a plugin (exifography) that imports the EXIF data for the image , and displays it in the post content, but can't get beyond that
Is there a similar example that we can see?
I've started with the travel reference site, as that does some of what i want to do. I still have to build the form for the images to be uploaded etc, but need to get the basics in place
What is the link to your site?
hidden link, hidden link

#1132956

I am using a plugin (exifography) that imports the EXIF data for the image , and displays it in the post content, but can't get beyond that
Hi, this sounds like something that will require a significant amount of custom code using PHP. If you're able to access the EXIF data in PHP during the save_post hook, you can save that data into a custom address field. I can show you how to save some arbitrary data to a custom field using PHP, but not how to access the EXIF data during the save_post hook. That will require assistance from your EXIF plugin developers or support team. Once you have that location data in a PHP variable, let's call it $location, then you can save that value to a custom address field like this:

update_post_meta( $post_id, 'wpcf-fieldslug', $location);

Change fieldslug to match your custom address field. This doesn't guarantee you'll store a mappable address, because there is no validation of the EXIF data against the Geocode API. Normally when using a custom address field, you must select a validated location from the autosuggest list. In your case, that validation is bypassed, so it's possible the location won't be plottable on a map.

#1133286

Hi Christian,
Thanks for the help so far. The plugin that I use, stores the EXIF data as media meta data.
hidden link

So what I want to do, is to read this meta data for the featured image, and save it as toolset custom fields for use with maps, but when we display it on the map, to use a less accurate location (i.e. remove some decimals) so we don't reveal the exact location

#1133448

when we display it on the map, to use a less accurate location (i.e. remove some decimals) so we don't reveal the exact location
If you want to store one accurate location but show a different location on the map, you need two custom fields to store both locations. For example, your two custom fields could be:
Specific location: 1600 Pennsylvania Ave NW, Washington DC 20500
General location: Washington DC 20500

To get metadata from a featured image, you need to access the featured image ID (_thumbnail_id from the postmeta table). Then you can use get_post_meta to access postmeta information.

$post_id = 12345; // the post with the featured image
$featured_id = get_post_meta( $post_id, '_thumbnail_id', true); // the featured image ID
$field = get_post_meta( $featured_id, 'fieldslug', true); // the value of the fieldslug custom field for the featured image