wordpress snippets last updated   : July 14, 2014
we now have 634 snippets

Display EXIF metadata in media library admin column

wordpress snippet

For anyone that uses wordpress for photography you should find this snippet useful. Adding this snippet to the functions.php of your wordpress theme will create a new column within the media library that will display EXIF metadata. Including, (credit, camera, focal length, aperture, iso, shutter speed, timestamp, copyright).

( example screenshot )
snippet :  PHPcopy
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];
	   }
    }
}

  • denny

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

    • http://wpsnipp.com Kevin Chard

      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.

      • denny

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

      • Denny – initial-blog.fr

        Hi, did you delete the snippset for the post?

  • ThunderStruck3

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

  • ThatGuy

    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’ );

    }

    }

    }

jqsnipp.com | we just launched jquery snippets website