我知道这是图像的新格式,但我不知道如何以HTML格式显示。有人知道我该怎么做吗?除chrome之外,哪个浏览器可以显示此图像格式?sample image
更新:新版本的浏览器可以支持此格式。
您可以像使用任何图像一样使用webp:
<img src="img.webp" />
但是由于并非始终受支持(请参阅http://caniuse.com/#feat=webp,因此您可以使用它来设置后备::
<picture>
<source srcset="img.webp" type="image/webp">
<source srcset="img.jpg" type="image/jpeg">
<img src="img.jpg">
</picture>
如果找不到指定路径的图像怎么办,在这种情况下如何显示无图像的图像,类似于以下内容:
<img src="img.jpg" onerror="this.src = 'nopicture.gif';"/>