/    Sign up×
Community /Pin to ProfileBookmark

AVIF and WEBP formats being ignored in “image-set” property in MOBILE

Hi!

I am optimizing our site by adding AVIF and WEBP versions of our images. Things are going well but there is something that is puzzling me and I have no idea what is causing it. One of the DIVs of our home page has a background image and I resolved it this way:

**HTML:**
`<div id=”searchbox” style=”–aspect-ratio: 16/9;background-size: cover; max-width:1132px;” class=”searchboxbg” ></div>`

**CSS:**

“`
.searchboxbg {
background-image: -webkit-image-set(url(/skins/default/images/tile_main_no_plate.avif) 1x, url(/skins/default/images/tile_main_no_plate.webp) 1x, url(/skins/default/images/tile_main_no_plate.jpg) 1x);
}
“`

When I test it in Chrome using the “desktop mode” everything works fine and it loads the image version AVIF for the background of the DIV (that’s the expected). However if I test it in “mobile mode” (F12 and then ctrl-shift-M to toggle mobile) it will ALWAYS skip AVIF and WEBP and load the JPG.

For testing purposes I made the following change in my CSS:

**CSS:**

“`
/* forcing AVIF format */
.searchboxbg {
background-image: url(/skins/default/images/tile_main_no_plate.avif);
}
“`

Doing this it DOES load the AVIF file no problem in mobile so the problem is not with the formats.

Does anyone know what may be causing it (and of course how to fix it)?

Thanks in advance!

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@SteamPunk_1966authorNov 08.2021 — We totally gave up about JPG, PNG etc and therefore we just hardcoded the background-image as AVIF (no further options) as we decided that the very small amount of users that still use very old browsers or iOS/Mac versions which don't support modern formats don't worth to sweat too much. It was our solution. 😀
×

Success!

Help @SteamPunk_1966 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...