WordPress 2.5 EXIF Fields

Posted: 2nd Apr 2008, in: Readers, plugins - Older Post - Newer Post

When I reviewed the photo gallery theme on monday I pointed to my photoblog where I was using it as an example. In some of my posts I was displaying the photo’s EXIF data and today someone asked me how I did that. The answer to that question is that I wrote a script a while back to do it for me; however, WordPress 2.5 has new capabilities and one of these is extracting IPTC and EXIF data from photographs when they are uploaded. So I set about finding out how to access it.

So far I haven’t been able to find any specific functions for displaying the data that is generated. I guess this is what Matt meant when he tagged it as a bonus feature. If anyone has any ideas about displaying it using template tags then let me know, but for the time being I have written a small plugin to display that data.

Here is a sample below:


Photo Data

  • Aperture - ƒ/4.5
  • Camera - Canon EOS 400D DIGITAL
  • Date Created - December 7, 2007, 12:55 pm
  • Focal length - 35mm
  • Iso - 1600
  • Shutter speed - 1/125

The plugin

Once downloaded and installed you need to include the following code in your post:

[photo-data:#]

Replace # with the ID of the attachement. This is easy to find by looking at the code that WordPress adds to your post. WordPress includes a class of wp-image-229, where 229 is the ID.

I have written this fairly quickly so it has been tested on one WordPress 2.5 blog: this one. I am happy to hear any suggestions about ways to improve it.

This has now been updated to take advantage of the shorttags in WordPress 2.5. It is also even easier to use because a URL can be passed instead of an ID. Please visit the link below for the read me file.

You can Download it here fun-with-photo-data

 

Comments

  1. 1

    Chris Osborne (http://sapidexistence.com) commented at 8:22 pm, 21st 06 2008:

    Is there a way to make this work with images hosted at Flickr?

     
  2. 2

    Andrew Rickmann (http://www.arickmann.co.uk) commented at 7:50 am, 22nd 06 2008:

    Chris,

    This pulls data from the WordPress database. It doesn’t read any information from the images themselves and so won’t work with images from anywhere else.

     
  3. 3

    Chris Osborne (http://sapidexistence.com) commented at 5:36 am, 23rd 06 2008:

    I figured that was the case when I read, but I thought I’d ask anyway.

    After looking around everywhere it seems that’s what all the plugins do. Just based purely on theoretical stuff, would it be easier for someone to work from this to get what I want or would it be better for me to start from scratch?

     
  4. 4

    Andrew Rickmann (http://www.arickmann.co.uk) commented at 7:15 am, 23rd 06 2008:

    Chris,

    I don’t know how Flickr handles these kinds of things but as it resizes images it may or may not remove the information from the image, so perhaps it is possible to extract the information from the image, or perhaps you would need to interface with the Flickr API and see if it is possible to pull the information out that way.

    Either way it is a completely different thing to what this plugin does so this plugin would be of no use as a starting point.

    As this does is pull information from the WordPress database and put it on screen. The WordPress core does the real work.

     
  5. 5

    Chris Osborne (http://sapidexistence.com) commented at 12:44 pm, 23rd 06 2008:

    What fun. The people over at Flickr think that if someone wants to see the EXIF, they should go over there and see it. And I’d rather let people see it right from my blog.

     
  6. 6

    Joshua (http://www.podq.com) commented at 10:59 pm, 1st 07 2008:

    Andrew,
    Fantastic plugin! I couldn’t figure out how in the world to have WordPress just do this itself, but this one works perfectly. What about the possibility of having it automatically insert the shortcode into any post that contains just one image, for example? (Just to save me some time! ;-)) Thanks again for the work!

     

Other blogs writing about this

  1. Shutter Themes | WP-Premiums (http://wp-premiums.com/2008/07/04/shutter-themes/) 04th 07 2008 at 12:15 pm

    [...] image resizing plugins and scripts out there (such as Viva Thumbs, TimThumb, or Get the Image), and Andrew of Fun with WordPress has created a plugin to facilitate the inclusion of EXIF [...]

     

Leave a Reply

I am currently testing a comment link policy which means commenters do not get a link. There is a poll, and open comments for feedback on the comment policy page.

Please note. I am currently using an experimental antispam technique on this blog. If you run into problems please let me know using the Get in Touch link at the top of the page. Thanks, Andy.

Subscribe without commenting

Feed Icon - Get fed with RSS