你可以在media_send_to_editor
筛选标题标记并将其添加到生成的HTML图像标记中:
function wpse_78529_restore_image_title( $html, $id ) {
/* retrieve the post object */
$attachment = get_post( $id );
/* if the title attribute is already present, bail early */
if ( strpos( $html, \'title=\' ) )
return $html;
/* retrieve the attached image attrbute */
$image_title = esc_attr( $attachment->post_title );
/* apply the title attribute to the image tag */
return str_replace( \'<img\', \'<img title="\' . $image_title . \'" \', $html );
}
add_filter( \'media_send_to_editor\', \'wpse_78529_restore_image_title\', 15, 2 );