Not sure if this is a Joomla issue or PHP?
When serving images we check to see if the browser support webp using
if (strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' )
We are fairly sure that this used to work, but my fellow webmaster recently checked and we were have only been serving JPEG images for quite some time.
I checked the header sent with the HTTP request (and same on Chrome and FF) and it had
Accept: image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5
which seems OK. However if I log the $_SERVER['HTTP_ACCEPT'] before the above code it shows:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Which explains why the webp is not being server. This was on our production server.
So I tried on my development (WIndows) system and got different results:
The header was:
Accept image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8
but my log now shows
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
which means the test passes. Now I realise that all browsers have supported webp for around 4 years so the test is not really needed in any case, but it certainly seems strange!
When serving images we check to see if the browser support webp using
if (strpos( $_SERVER['HTTP_ACCEPT'], 'image/webp' )
We are fairly sure that this used to work, but my fellow webmaster recently checked and we were have only been serving JPEG images for quite some time.
I checked the header sent with the HTTP request (and same on Chrome and FF) and it had
Accept: image/avif,image/webp,image/png,image/svg+xml,image/*;q=0.8,*/*;q=0.5
which seems OK. However if I log the $_SERVER['HTTP_ACCEPT'] before the above code it shows:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Which explains why the webp is not being server. This was on our production server.
So I tried on my development (WIndows) system and got different results:
The header was:
Accept image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8
but my log now shows
text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
which means the test passes. Now I realise that all browsers have supported webp for around 4 years so the test is not really needed in any case, but it certainly seems strange!
Statistics: Posted by MrDog — Fri Jan 10, 2025 11:50 pm