我正在尝试使用Wordpress Core响应式图像功能,但未在图像中添加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="">
如果我从the_post_thumbnail中删除图像大小并仅使用the_post_thumbnail();它可以处理自适应图像,但没有我的尺寸
<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">
我该如何解决?