I refactored my app with avif format for phone devices (even if it's not supported everywhere).
This code works perfectly, it prioritize avif format if it's supported by the browser:
<picture>
<source srcset="image.avif" media="(max-width:500px)" type="image/avif" />
<img src="image.jpg" alt="nice dog" />
</picture>
But I also got some images as background-image
css property. I tried the image-set property but without success.
div {
background-image: -webkit-image-set(
url('image.avif') type("image/avif"),
url('image.jpg') type("image/jpeg"));
background-image: image-set(
url('image.avif') type("image/avif"),
url('image.jpg') type("image/jpeg"));
}
I looked at the example 2 here. Even Firefox nor chrome doesn't interpret well this code. Any idea ? Am I trying something that is still in draft for browsers ?