Warning: Undefined array key "night" in /www/wwwroot/dhaomu.com/wp-content/themes/b2/header.php on line 18

WordPress移除图片的高度和宽度属性

wordpress教程:移除图片的高度和宽度属性!定义wordpress主题样式的时候,有可能需要移除本身图片的宽度和高度属性来方便我们使用CSS定义。

wordpress教程:移除图片的高度和宽度属性!定义wordpress主题样式的时候,有可能需要移除本身图片的宽度和高度属性来方便我们使用CSS定义。

将下面代码添加到主题的functions.php即可

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;
}
温馨提示:
1.本站大部分内容均收集于网络!若内容若侵犯到您的权益,请发送邮件至:duhaomu@163.com,我们将第一时间处理!
2.资源所需价格并非资源售卖价格,是收集、整理、编辑详情以及本站运营的适当补贴,并且本站不提供任何免费技术支持。
3.所有资源仅限于参考和学习,版权归原作者所有,更多请阅读网站声明

给TA赞赏
共{{data.count}}人
人已赞赏
编程技巧

PbootCMS模板上传后前台页面是乱的怎么处理

2023-6-9 9:00:00

编程技巧

WordPress的Gravatar头像被墙及解决方案

2023-6-12 0:00:00

0 条回复 A文章作者 M管理员

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914

Warning: Trying to access array offset on value of type null in /www/wwwroot/dhaomu.com/wp-content/themes/b2/functions.php on line 3914
----《》
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索