WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Retrieving Exif Data (5 posts)

  1. bondbloke
    Member
    Posted 2 years ago #

    I am trying to create a photoblog theme, and what I wnat to do is have the photo in one <div> and the relevant exif data for it in another <div> to the right. I am pretty sure that WP extracts and stores the exif date when an image is uploaded, but I am damned if I can find where it stores the info, or how I can pull it out for use.

    Would very much appreciate any ideas...

  2. i_g_wright
    Member
    Posted 2 years ago #

    Hi,

    This website should help you out: http://www.bloggingtips.com/2008/07/20/wordpress-gallery-and-exif/

    Thank you,

  3. bondbloke
    Member
    Posted 2 years ago #

    Thanks for that i_g_wright, I have read that through several times, and tried most of what is suggested, but it only seems to work in the context of a gallery which is not what I am trying to do.

    What I am trying tp do is have a single post with a photo and the exif data next to it with next and previous links to work forwards and backwards through the images. At this point everything I try returns no information at all. My thinking is that when WP (on uploading) creates smaller images it wipes out the exif data on these smaller images, which has to be retrieved from the original image, and that is what I can't get my head around right now.

  4. i_g_wright
    Member
    Posted 2 years ago #

    Hi,

    Ok, in your single post template (PHP file) you should be able to use the following code:

    <h1>Attached Images & Exit Data</h1>
    <?php
    $args = array(
       'post_type' => 'attachment',
       'numberposts' => -1,
       'post_status' => null,
       'order'	=> 'ASC',
       'post_parent' => $post->ID
      );
    $attachments = get_posts( $args );
         if ( $attachments ) {
            foreach ( $attachments as $attachment ) {
               $imgmeta = wp_get_attachment_metadata( $attachment->ID );
               echo '<pre>';
               print_r( $imgmeta );
               echo '</pre>';
              }
         }
    ?>

    This code will print out an array of all the image sizes available and the image exif data.

    To print out each item separately you can use the following formats (As stated from the website above)

    $imgmeta['image_meta']['aperture']
    $imgmeta['image_meta']['credit']
    $imgmeta['image_meta']['camera']
    $imgmeta['image_meta']['caption']
    $imgmeta['image_meta']['created_timestamp']
    $imgmeta['image_meta']['copyright']
    $imgmeta['image_meta']['focal_length']
    $imgmeta['image_meta']['iso']
    $imgmeta['image_meta']['shutter_speed']
    $imgmeta['image_meta']['title']

    I hope that helps,

  5. bondbloke
    Member
    Posted 2 years ago #

    Thanks i_g you're a genius, that works perfectly...

Topic Closed

This topic has been closed to new replies.

About this Topic