我正在尝试删除帖子缩略图的title属性(在某些帖子上),我假设get\\u image\\u标记过滤器就是这样做的。然而,到目前为止,我所得到的并不奏效。我需要做什么改变才能使这项工作正常进行?我的代码:
add_filter(\'get_image_tag\', \'image_no_title\');
function image_no_title($title) {
$title = \'\';
return $title;
}
以及相关函数(来自wp includes/media.php):
function get_image_tag($id, $alt, $title, $align, $size=\'medium\') {
list( $img_src, $width, $height ) = image_downsize($id, $size);
$hwstring = image_hwstring($width, $height);
$class = \'align\' . esc_attr($align) .\' size-\' . esc_attr($size) . \' wp-image-\' . $id;
$class = apply_filters(\'get_image_tag_class\', $class, $id, $align, $size);
$html = \'<img src="\' . esc_attr($img_src) . \'" alt="\' . esc_attr($alt) . \'" title="\' . esc_attr($title).\'" \'.$hwstring.\'class="\'.$class.\'" />\';
$html = apply_filters( \'get_image_tag\', $html, $id, $alt, $title, $align, $size );
return $html;
}