如何在image_tag rails中显示带有后备URL的webp图像

问题描述 投票:0回答:1

我想在image_tag rails中显示带有后备网址的webp图片网址。

现在它的<%= image_tag "profile.webp",:class=>"profile" %>

如何为webp无法正常工作的浏览器添加jpg网址的后备网址

ruby-on-rails ruby image webp
1个回答
0
投票

遗憾的是,使用rails helper(image_tag)是不可能的。

你可以看看https://github.com/kavu/sprockets-webp作为一种可能的解决方案,然而,这增加了很多复杂性。

你最好的选择是使用JS解决这个问题:https://developers.google.com/speed/webp/faq

© www.soinside.com 2019 - 2024. All rights reserved.