You can use wp_generate_attachment_metadata
:
This function generates metadata for an image attachment. It also creates a thumbnail and other intermediate sizes of the image attachment based on the sizes defined on the Settings_Media_Screen.
The second argument of the filter is the attachment ID, so it shouldn't be a problem to add the post meta:
add_filter( 'wp_generate_attachment_metadata', 'manipulate_metadata_wpse_91177', 10, 2 );
function manipulate_metadata_wpse_91177( $metadata, $attachment_id )
{
// var_dump( $metadata['image_meta'] );
// Credit is inside $metadata['image_meta']['credit']
return $metadata;
}
Inspecting the contents of $metadata['image_meta']
with FirePHP, these are the results:
aperture: 4
camera: "DMC-FZ100"
caption: ""
copyright: ""
created_timestamp: 1352136868
credit: ""
focal_length: "9.2"
iso: "100"
shutter_speed: "0.003125"
title: "Double Dip"
[Update]
Full test adding a custom column in Media Library screen (/wp-admin/upload.php
) to display the post meta info:
add_filter( 'wp_generate_attachment_metadata', 'manipulate_metadata_wpse_91177', 10, 2 );
add_filter( 'manage_upload_columns', 'camera_info_column_wpse_91177' );
add_action( 'manage_media_custom_column', 'camera_info_display_wpse_91177', 10, 2 );
function manipulate_metadata_wpse_91177( $metadata, $attachment_id )
{
update_post_meta( $attachment_id, 'photo_title', $metadata['image_meta']['title'] );
update_post_meta( $attachment_id, 'photo_camera', $metadata['image_meta']['camera'] );
return $metadata;
}
function camera_info_column_wpse_91177( $columns )
{
$columns['cam_info'] = 'Camera Info';
return $columns;
}
function camera_info_display_wpse_91177( $column_name, $post_id )
{
if( 'cam_info' != $column_name || !wp_attachment_is_image( $post_id ) )
return;
$title = get_post_meta( $post_id, 'photo_title', true );
$camera = get_post_meta( $post_id, 'photo_camera', true );
$echo_title = $title ? 'Title: ' . $title . '<br />' : '';
$echo_camera = $camera ? 'Camera: ' . $camera : '';
echo $echo_title . $echo_camera;
}
Somewhat related Q&A: Create new category upon save based on post information