Opened 2 years ago
Last modified 22 months ago
#16251 new enhancement
Change attachment image uploads to have post_date corresponding to EXIF created date
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Media | Version: | |
| Severity: | normal | Keywords: | dev-feedback |
| Cc: |
Description
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;
}
Change History (4)
comment:3
solarissmoke — 2 years ago
- Keywords dev-feedback added
comment:4
SergeyBiryukov — 22 months ago
#17485 has more discussion on this.
Note: See
TracTickets for help on using
tickets.

This is not so simple - post_date is implicitly assumed to be the date of upload:
IMO it may be better to leave post_date as the uploaded date, and read the creation date metadata manually as/when needed.