It seems that Wordpress use the exif title to fill the caption field, but I need it to use the exif copyright data instead to give automaticaly credit to photographers. What code should I use, please help me because I can't find clear examples of that action.
<?php
add_action( 'add_attachment', 'my_set_image_meta_upon_image_upload' );
function my_set_image_meta_upon_image_upload( $post_ID ) {
if ( wp_attachment_is_image( $post_ID ) ) {
$my_image_title = get_post( $post_ID )->post_title;
// Both give illegal string offset 'image_meta'
$meta_data = wp_read_image_metadata( $post_ID )['image_meta'];
$meta_data = wp_get_attachment_metadata( $post_ID )['image_meta'];
$my_image_meta = array(
'ID' => $post_ID,
'post_excerpt' => $meta_data['copyright'],
'post_content' => $meta_data['copyright'],
);
update_post_meta( $post_ID, '_wp_attachment_image_alt', $meta_data );
wp_update_post( $my_image_meta );
}
}