Created
February 4, 2013 16:24
-
-
Save tlovett1/4707773 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pmc_variety_image_credit( $form_fields, $attachment ) { | |
$image_credit = array( | |
'label' => 'Image Credit', | |
'value' => get_post_meta( $attachment->ID, '_image_credit', true ), | |
'helps' => 'Image credit, e.g. "Copyright ' . date('Y') . ' Getty Images".', | |
'show_in_edit' => true, | |
); | |
$form_fields['image_credit'] = $image_credit; | |
return $form_fields; | |
} | |
add_filter( 'attachment_fields_to_edit', 'pmc_variety_image_credit', 10, 2 ); | |
function pmc_variety_image_credit_save( $post, $attachment ) { | |
if ( isset($attachment['image_credit']) ) { | |
$image_credit = trim( strip_tags( $attachment['image_credit'] ) ); | |
update_post_meta( $post['ID'], '_image_credit', $image_credit ); | |
} | |
return $post; | |
} | |
add_filter( 'attachment_fields_to_save', 'pmc_variety_image_credit_save', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment