X

Display EXIF Metadata in Media Library Admin Column

Snippets by IsItWP

EXIF metadata includes credit, camera, focal length, aperture, iso, shutter speed, timestamp, copyright, etc. You can display this EXIF metadata with your images in WordPress media library.

Instructions: Add the following code to the functions.php file of your WordPress theme.

add_filter('manage_media_columns', 'posts_columns_attachment_exif', 1);
add_action('manage_media_custom_column', 'posts_custom_columns_attachment_exif', 1, 2);

function posts_columns_attachment_exif($defaults){
    $defaults['wps_post_attachments_exif'] = __('EXIF');
    return $defaults;
}
function posts_custom_columns_attachment_exif($column_name, $id){
	if($column_name === 'wps_post_attachments_exif'){
           $meta = wp_get_attachment_metadata($id);

	   if($meta[image_meta][camera] != ''){
           echo "CR:  ".$meta[image_meta][credit]."<hr />";
           echo "CAM:  ".$meta[image_meta][camera]."<hr />";
           echo "FL:  ".$meta[image_meta][focal_length]."<hr />";
           echo "AP:  ".$meta[image_meta][aperture]."<hr />";
           echo "ISO:  ".$meta[image_meta][iso]."<hr />";
           echo "SS:  ".$meta[image_meta][shutter_speed]."<hr />";
           echo "TS:  ".$meta[image_meta][created_timestamp]."<hr />";
           echo "C:  ".$meta[image_meta][copyright];
	   }
    }
}

You may also enjoy removing featured image meta box.

Comments   Leave a Reply

  1. Made a few minor changes to prevent notices, and changed the HR to |
    —-

    function posts_custom_columns_attachment_exif($column_name, $id){

    if($column_name === ‘wps_post_attachments_exif’){

    $meta = wp_get_attachment_metadata($id);

    if(isset($meta[‘image_meta’][‘camera’])){

    echo “CR: ” . $meta[‘image_meta’][‘credit’] .’ | ‘;

    echo “CAM: ” . $meta[‘image_meta’][‘camera’] .’ | ‘;

    echo “FL: ” . $meta[‘image_meta’][‘focal_length’] . ‘ | ‘;

    echo “AP: ” . $meta[‘image_meta’][‘aperture’] .’ | ‘;

    echo “ISO: ” . $meta[‘image_meta’][‘iso’] . ‘ | ‘;

    echo “SS: ” . $meta[‘image_meta’][‘shutter_speed’] . ‘ | ‘;

    echo “TS: ” . $meta[‘image_meta’][‘created_timestamp’] . ‘ | ‘;

    echo “C: ” . $meta[‘image_meta’][‘copyright’] : ‘N/A’ );

    }

    }

    }

  2. Any way to get this to show up every time with an image? Maybe make this automatically inserted into the description field?

  3. great snippets, a little big for admin, but can we use it in our blog when we are over the picture?

    1. It is a little big but could be adjusted with css. In regards to this snippet you can display things within your page using a similar method as $meta = wp_get_attachment_metadata($id); will get the meta data you just need to pass the attachment id. Ill make a post in the near future to display these details with your pictures.

      1. Ok, thanks for your reply.
        And thanks for the next posts

      2. Denny - initial-blog.fr January 18, 2012 at 12:25 pm

        Hi, did you delete the snippset for the post?

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!