images - max_srcset_image_width doesn't work as intended

I register a new image size in my theme, i.e:add_image_size('home-slide', 1500, 756, true);and I set the maxim

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?

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745615653a4636218.html

相关推荐

  • images - max_srcset_image_width doesn&#39;t work as intended

    I register a new image size in my theme, i.e:add_image_size('home-slide', 1500, 756, true);and I set the maxim

    9小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信