[wp-trac] [WordPress Trac] #16251: Change attachment image uploads to have post_date corresponding to EXIF created date

WordPress Trac wp-trac at lists.automattic.com
Sat Jan 15 23:03:15 UTC 2011


#16251: Change attachment image uploads to have post_date corresponding to EXIF
created date
--------------------------+-----------------------------
 Reporter:  Otto42        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Media         |    Version:
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 General idea is that if an image has EXIF data about its creation time, we
 should use that as the post_date in the attachment post, since the
 attachment post is the representation in WordPress of the attachment file.

 Advantages: The posts will show their proper dates of creation by simply
 using the_date and similar functions.

 This code will do it as a plugin. A patch would be much simpler and more
 generally beneficial.

 {{{
 add_filter('wp_update_attachment_metadata','attachment_redater',10,2);
 function attachment_redater($data, $id) {
         if (!empty($data['image_meta']['created_timestamp'])) {
                 $post=get_post($id);
                 $post->post_date = gmdate('Y-m-d H:i:s',
 $data['image_meta']['created_timestamp']);
                 wp_update_post($post);
         }
         return $data;
 }

 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16251>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list