admin管理员组文章数量:1434125
I register a new image size in my theme, i.e:
add_image_size('home-slide', 1500, 756, true);
and I set the maximum size for the srscet
attribute of responsive images to 1024
:
function set_max_srcset_image_width( $max_width ) {
$max_width = 1024;
return $max_width;
}
add_filter( 'max_srcset_image_width', 'set_max_srcset_image_width' );
Finally, I show my image in the posts loop with:
<img src="<?php echo wp_get_attachment_image_url( 7, 'home-slide' ) ?>"
srcset="<?php echo wp_get_attachment_image_srcset( 7, 'home-slide' ) ?>"
sizes="<?php echo wp_get_attachment_image_sizes( 7, 'home-slide' ) ?>" />
But I get the following markup:
<img src=".jpg" srcset="" sizes="(max-width: 1500px) 100vw, 1500px">
Why?
本文标签: imagesmaxsrcsetimagewidth doesn39t work as intended
版权声明:本文标题:images - max_srcset_image_width doesn't work as intended 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745615653a2666383.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论