記事に、「メディアを追加」で画像を追加するとき、「タイトル」でimgタグのtitle属性を設定するわけですが、この初期値は画像のファイル名になってまして、そのまま公開してしまうと画像にマウス当てたらファイル名がポップアップしてしまう、なんてことになりかねません。title属性自体を挿入させない方法は広く知られていますが、それだといざtitle属性を使いたいときに不便です。なので、初期値を空白にしてしまいましょう。
このコードをfunctions.phpにどうぞ。
add_filter('wp_prepare_attachment_for_js', function($response, $attachment, $meta){
$response['title'] = '';
return $response;
}, 10, 3);
このフックは/wp-includes/media.phpに定義されていて、$responseに入っているものを抜き出してみると、
$response = array(
'id' => $attachment->ID,
'title' => $attachment->post_title,
'filename' => wp_basename( $attachment->guid ),
'url' => $attachment_url,
'link' => get_attachment_link( $attachment->ID ),
'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
'author' => $attachment->post_author,
'description' => $attachment->post_content,
'caption' => $attachment->post_excerpt,
'name' => $attachment->post_name,
'status' => $attachment->post_status,
'uploadedTo' => $attachment->post_parent,
'date' => strtotime( $attachment->post_date_gmt ) * 1000,
'modified' => strtotime( $attachment->post_modified_gmt ) * 1000,
'menuOrder' => $attachment->menu_order,
'mime' => $attachment->post_mime_type,
'type' => $type,
'subtype' => $subtype,
'icon' => wp_mime_type_icon( $attachment->ID ),
'dateFormatted' => mysql2date( get_option('date_format'), $attachment->post_date ),
'nonces' => array(
'update' => false,
'delete' => false,
'edit' => false
),
'editLink' => false,
'meta' => false,
);
となってます。$attachmentには画像の投稿情報(「メディア」に保存してある画像はattachmentという種類の「投稿」として扱われます)、$metaには画像のサイズやURLなどのメタ情報(詳しくはCodexのwp_get_attachment_metadataのページの「Return Values」の項参照)が入ってますので、それらを組み合わせていろんな初期値を設定することも可能です。