WordPress 使用以下属性渲染缩略图:
<img width="100" height="200" ...
IE7\8 要求是这样的:
<img width="100px" height="200px" ...
(确切的问题在这里:WordPress特色图像未显示在IE8中)
我深入研究了核心,找到了渲染高度\宽度的代码:http://core.trac.wordpress.org/browser/trunk/wp-includes/media.php#L223
我的问题:你能帮我一个自定义函数将px部分添加到$hwstring中吗(函数在这里:http://core.trac.wordpress.org/browser/trunk/wp-includes/media.php#L98 )
提前感谢您的每一个提示。
试试这个;
function custom_dimensions($html, $id, $alt, $title, $align, $size){
$html = preg_replace('%(width|height)(="[0-9]{1,4})(")%', '$1$2px$3', $html);
return $html;
}
add_filter('get_image_tag', 'custom_dimensions',1, 6);
我只是在最后快速测试了它。