Last week, after I got my camera I started working to customize my photo galleries through the Wordpress gallery shortcode. Like everyone else who’s tried, my inspiration was the near perfect design of Ma.tt. One of my favorite features of his gallery is the inclusion of the EXIF profile for each photo on it’s attachment page.
For those who don’t know, EXIF is the exchangeable image file format used to encode details about a photo in the file itself. It records things like shutter speed, aperture, and camera model. Among other things, it can help others see how you achieved the shot, or record where you were (via GPS data, which you can add in Picasa).
I couldn’t get my fields to populate, and found out that there is a required server extension, php_exif, that was probably not enabled on my hosting server. I called my provider, sat on hold for 30 minutes, and got the rough word that it’s not allowed on my shared hosting plan. I’d have to shell out $25/month, or find another way.
I came across php library called Exifer, written by Jake Olefsky, and maintained at Zen Photo. It parses the EXIF data, turning the numerical keys in to strings, and placing them in a multilayer array.
This plugin uses the library to extract the data and displays it as an unordered list on the attachment page below the photo. When you create your gallery make sure you set it to link to “attachment page”. The plugin will automatically insert the code after the image, unless you are using an attachment.php or image.php template. And if your image has no EXIF data, nothing will display.
If you are using one of those templates, simply insert this after the image in your template file:
<?php ec_get_image_exif(); ?>
If you’d like to see the raw output, you can uncomment this in gallery-exif-reader.php (if using a template, place the function on the page):
add_filter('the_content', 'ec_exif_reader_debug', 1);
You can look at this output to see if there’s any other info you want to include, then add it in this form:
$output .= "<li><span class="\"exifTitle\"">Aperture</span> " . $exif_array['SubIFD']['ApertureValue'] . "</li>\n";
For template users:
echo "<li><span class="\"exifTitle\"">Aperture</span> " . $exif_array['SubIFD']['ApertureValue'] . "</li>\n";
You can style the output through the included css file. The date is set to display “mm.dd.yyyy”. You can adjust it by changing
$exif_date
to your preferred format. Check out PHP.net for usage.
Changelog:
** 0.9.3 (6/8/09) **
Added new function (ec_get_item_exif) which takes either the url of the full-sized image (including “http://”) or the attachment ID.
** 0.9.2 (4/7/09) **
By default the date will display in the format set in Settings > General.** 0.9.1b (3/29/09) **
Not all files were included in subversion-generated zip archive.** 0.9.1a (3/29/09) **
Repaired incorrect path to stylesheet.< **0.9.1 Bugfix (3/29/09)**
After editing Picasa strips “ApertureValue” from the data in favor of “FNumber”. WPG-ER now checks both.
Forced FNumber to round to 1 decimal.
Shooting date is now determined by “DateTimeOriginal”, rather than “DateTime”.
Download WP Gallery EXIF Reader (220).
Charles
Michel,
Is #3 saying that you aren’t using an attachment.php or image.php? If not, you shouldn’t need to make any adjustments to anything.
What theme are you using? Are you using any other plugins that affect the gallery or images (like a lightbox?) There may be a conflict. If there is, let me know, so I can fix it.
Michel777
Charles,
thans a lot for your effort and for your effort. Actually I’m using my own themes, they are very simple this time I have only an index.php (footer + header). In index.php I’m using Mootools FX.slide. The only plugin is yours. I also tested with theme “classic” – it doesn’t work either. Probably I “destroyed” anything – because I remember it worked a few days ago. I’ll start again from begin, I reinstall WP. If I will still have troubles, I will ask you again.
Thanks again and have a nice evening,
Michel
John
Hi Charles. Nice plugin. How would one add fields specified in Adobe Bridge like IPTC core – Keywords, Description, Country, …) ?
More from authorSorry, I tried adding the
$output .= "Keywords " . $exif_array['SubIFD']['Keywords']."\n";…sorry, I really don’t understand.