Answer the question
In order to leave comments, you need to log in
How to insert .webp images through background?
How to insert .webp images through background? You say
"What nonsense? You write background: url(img/image.webp); Profit!"
<picture class="information__image">
<source type="image/webp" srcset="img/phones/phone1.webp 1x, img/phones/[email protected] 2x, img/phones/[email protected] 3x">
<source type="image/png" srcset="img/phones/phone1.png 1x, img/phones/[email protected] 2x, img/phones/[email protected] 3x">
<img src="img/phones/phone1.png" alt="text">
</picture>
Answer the question
In order to leave comments, you need to log in
Create a validation function
function ThisIsWebP() {
var def = $.Deferred(), crimg = new Image();
crimg.onload = function() { def.resolve(); };
crimg.onerror = function() {def.reject(); };
crimg.src = "https://simpl.info/webp/cherry.webp";
return def.promise();
}
ThisIsWebP().then(function() {
//Есть поддержка webp
}, function() {
//Нет поддержки webp
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question