How to add a credit line to a photo caption
I'm trying to find a way to automatically add a photographer credit line to user-inserted photos. I've added custom fields to the media uploader for 'Photographer Name' and 'Photographer URL' but I can't figure out a way to automatically insert the input from these fields into the caption field so that they will automatically display with the photo.
Here's the code to generate the custom fields:
function attachment_field_credit( $form_fields, $post ) {
$form_fields['photographer-name'] = array(
'label' = 'Photographer Name',
'input' = 'text',
'value' = get_post_meta( $post-ID, 'photographer_name', true ),
'helps' = 'If provided, photo credit will be displayed',
);
$form_fields['photographer-url'] = array(
'label' = 'Photographer URL',
'input' = 'text',
'value' = get_post_meta( $post-ID, 'photographer_url', true ),
'helps' = 'Add Photographer URL',
);
return $form_fields;
}
add_filter( 'attachment_fields_to_edit', 'be_attachment_field_credit', 10, 2 );
Thanks for your help.