【发布时间】:2014-02-25 21:41:58
【问题描述】:
有没有人找到方法来更好地控制使用 Wordpress Jetpack“通过电子邮件发布”功能时创建的图像?
理想情况下,当通过电子邮件发布时,我希望我的图片与电子邮件附件的大小相同。正如通过电子邮件发布一样,只会将它们最大化为 1024x1024。
【问题讨论】:
有没有人找到方法来更好地控制使用 Wordpress Jetpack“通过电子邮件发布”功能时创建的图像?
理想情况下,当通过电子邮件发布时,我希望我的图片与电子邮件附件的大小相同。正如通过电子邮件发布一样,只会将它们最大化为 1024x1024。
【问题讨论】:
您可以通过将以下代码插入到您的functions.php中来解决此问题
add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'the_content', 'remove_width_attribute', 10 );
function remove_width_attribute( $html ) {
$html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
return $html;
}
如此处所述:http://css-tricks.com/snippets/wordpress/remove-width-and-height-attributes-from-inserted-images/
【讨论】: