默认添加到WordPress的内容中的图片会自带尺寸高度和宽度,有时候限制我们原本的图片尺寸。这我们可以禁止掉这些默认参数,采用固有的图片的尺寸。
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
这样就去掉WordPress的限制尺寸。
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END