似乎 Wordpress 使用 exif 标题来填充标题字段,但我需要它来使用 exif 版权数据,而不是自动将功劳归功于摄影师。我应该使用什么代码,请帮助我,因为我找不到该操作的明确示例。
<?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 );
}
}