Description: I am trying to display .AVIF images on Chrome and newer browsers, while showing .GIF images on browsers like Safari that do not properly support .AVIF images. However, on Safari, the .AVIF image is still being requested, and an empty space is being shown where the image should be. This issue occurs on Safari (PC + Mobile).
Code:
<picture>
<source type="image/avif" srcset="https://overpadel.nl/wp-content/uploads/browser-test1.avif" />
<source type="image/gif" srcset="https://overpadel.nl/wp-content/uploads/browser-test1.gif" />
<img src="https://overpadel.nl/wp-content/uploads/browser-test1.gif" alt="" />
</picture>
Question: Any tips on how to get the .GIF image to display on Safari instead of the .AVIF image? What am I missing?
Having had this same problem, I did a reasonably thorough check using Browserstack, and determined that this affected around 1.5% of my website users, with the following profile:
So as @user2283347 suggests, I'm testing the user agent and disabling the AVIF function if a buggy version is found. Here's my PHP code:
It's ugly, but it appears to do the job, and I don't have any better ideas.