Hi. I’ve been digging through the documentation and am interested in using the attachment_fields_to_save function to set a default caption value when new images are uploaded.
Based on the example usage, http://codex.wordpress.org/Plugin_API/Filter_Reference/attachment_fields_to_save, I created as simple function to set a generic value, and place it in a custom plug-in that I’m using. The plug-in is working fine, and is activated, but the code isn’t working. I’ve also tried putting int the functions.php file, to no avail.
function insert_custom_default_caption($post, $attachment) {
if ( substr($post['post_mime_type'], 0, 5) == 'image' ) {
$post['post_excerpt'] = 'default caption';
}
return $post;
}
add_filter('attachment_fields_to_save', 'insert_custom_default_caption', 10, 2);
Any suggestions would be greatly appreciated. Based on some cursory Google searches, it seems like other people are trying to accomplishing this same thing. Cheers!