Wordpress从3.5版起删除了图像标题。
我在我的主题函数中使用这些函数。php将其带回:
add_filter( \'media_send_to_editor\', \'rgbtoi_restore_image_title\', 15, 2 );
function rgbtoi_restore_image_title( $html, $id ) {
$attachment = get_post($id);
if (strpos($html, "title=")) {
return $html;
} else {
$mytitle = esc_attr($attachment->post_title);
return str_replace(\'<img\', \'<img title="\' . $mytitle . \'" \' , $html);
}
}
add_filter(\'wp_get_attachment_image_attributes\',\'rgbtoi_image_titles\', 10, 2);
function rgbtoi_image_titles($atts,$img) {
$atts[\'title\'] = trim(strip_tags( $img->post_title ));
return $atts;
}