Image Metadata in WordPress

WordPress saves some meta data of the uploaded images, as far as it is possible to extract them. I will show you how to display this infos right under the picture.

All we need is one function in functions.php:

function myMetaData($pic) {
  $html = '';
  $meta = wp_get_attachment_metadata($pic);
  if($meta) {
      $html = '<ul>';
      foreach($meta['image_meta'] as $key => $value) {
          $html .= '<li>' . $key . ': <strong>' . $value . '</strong></li>';
      $html .= '</ul>';
  return $html;

In image.php of the default theme we are inserting above the_content (Line 12) the new function:

<?php  echo myMetaData($post->ID); ?>

This is how it looks in the default theme::

WordPress Image Meta Data

Comments are closed.


  1. Chris

    This is very cool… I will need to keep this info handy – delicious here I come!!

  2. Andrew

    I wrote a plugin to do that a little while back. One of the users jumped in and added some extra code to format the results a little better, so you might want to take a look.

  3. Michael

    Nice idea, Andrew!
    Yes, the results are not formatted, but i wanted to show how simple it is in WordPress to make such things.

  4. Ramona

    For public relations it would be interesting to show date, author, copyright and other IPTC data. How is it possible to select?

  5. Michael

    @Ramona: WordPress doesn’t save those values. You have to extend the functionallity with the php function exif_read_data.