我试图弄清楚如何在wordpress中创建替代图像格式。 我正在通过rest api获取图像源,并将其用作Nuxt.js中的vue变量。
<picture>
<source srcset="xxx.webp" type='image/webp'>
<source srcset="xxx.jpg" type='image/jpeg'>
<img src="xxx.jpg" alt='xxx'>
</picture>
我看到的制作方法是上传具有相同名称但格式不同的图像,然后获取主图像,删除其格式并像这样添加它
<picture>
<source :srcset="srcVariable + 'webp'" type='image/webp'>
<source :srcset="srcVariable + 'jpg'" type='image/jpeg'>
<img :src="'srcVariable + 'jpg'"" alt='xxx'>
</picture>
我不确定它会如何工作,但我在这里问也许是更好的解决方案或wordpress插件来实现它的更好方法