admin管理员组文章数量:1434908
I have a callback applied to wp_get_attachment_image_attributes
to add attributes to the generated image html.
function add_lazyload_to_attachment_image($attr, $attachment)
{
if (strpos($attr['class'], 'lazyload') !== false) {
$attr['data-src'] = $attr['src'];
if (isset($attr['srcset'])) {
$attr['data-srcset'] = $attr['srcset'];
$attr['data-sizes'] = "auto";
$attr['srcset'] = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
}
}
return $attr;
}
add_filter('wp_get_attachment_image_attributes', 'add_lazyload_to_attachment_image', 30, 2);
But the function does not get applied some custom image sizes. This filter works for the default image sizes present in Wordpress.
I want this filter to work for all custom image sizes. Please help.
本文标签: attachmentsFilter not applied to all image sizes
版权声明:本文标题:attachments - Filter not applied to all image sizes 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745625357a2666935.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论