When I upload images, Wordpress 3.4.2 sets the Title to the base of the filename, such as "DSCN1234" or "IMG_1234". I'd like the Title to be left blank.
The code that sets the Title during the upload seems to be in "wp-admin/includes/media.php" in the function
// Construct the attachment array $attachment = array_merge( array( 'post_mime_type' => $type, 'guid' => $url, 'post_parent' => $post_id, 'post_title' => $title, 'post_content' => $content, ), $post_data );
If I just change it to
'post_title' => "", it fixes it, but I understand that the core code shouldn't be modified.
Is there a filter I can use to modify the Title after it's been set by the upload handler? I tried
wp_handle_upload_prefilter but they don't give me access to the
attachment_fields_to_edit does give me access to
post_title, but it's fired for every image when editing a gallery -- I just want to modify the
post_title of a single image immediately after it's uploaded. (if the user manually sets the Title to the filename afterward, I don't want to remove it.) Any other ideas?
UPDATE: well, I just discovered that the
post_title is set back to the file name every time the gallery is updated (re-sorting images, etc.) And even if I use the
attachment_fields_to_edit filter to clear the
post_title, it doesn't stay cleared because when I click Save Changes, something is apparently not liking the fact that I've set the Title field to be empty even though it's a required field (red asterisk next to it). Other ideas appreciated.