我正在尝试使用wordpress核心响应图像功能,但它并没有将srcset添加到图像中。这是我的密码
我有一个div w=370px h=280px现在我添加了图像大小
if(function_exists(\'add_image_size\')){
add_image_size( \'imagebox\', 370, 280, true );
add_image_size( \'imagebox-2x\', 840, 560, true );
add_image_size( \'imagebox-3x\', 1110, 840, true );}
然后像这样在循环中调用它
the_post_thumbnail(\'imagebox-2x\');
它只添加了像这样的2x版本的图像,没有srcset
<img width="840" height="560" src="http://localhost/starter/wp-content/uploads/2018/10/04004_theblackandwhiterocky_2560x1600-840x560.jpg" class="attachment-imagebox-2x size-imagebox-2x wp-post-image" alt="">
如果我从\\u post\\u缩略图中删除图像大小并仅使用\\u post\\u缩略图();它可以处理灵敏的图像,但不需要我的尺寸
<img width="180" height="180" src="http://localhost/starter/wp-content/uploads/2018/10/04004_theblackandwhiterocky_2560x1600-180x180.jpg" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" alt="" srcset="http://localhost/starter/wp-content/uploads/2018/10/04004_theblackandwhiterocky_2560x1600-180x180.jpg 180w, http://localhost/starter/wp-content/uploads/2018/10/04004_theblackandwhiterocky_2560x1600-150x150.jpg 150w" sizes="(max-width: 180px) 100vw, 180px">
我怎样才能解决这个问题?