Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebP Formatted images not Always Displaying on iOS

Tags:

ios

image

webp

In order to speed HTML page loads, I've converted images to webp format and use the "picture" element as follows:

<picture>
    <source data-srcset="images/gallery/urban.webp" type="image/webp">
    <source data-srcset=images/gallery/urban.jpg" type="image/jpeg">
    <img data-src="images/gallery/urban.jpg" alt="Alt Title" style="">
</picture>

On my tests in Chrome, IE, Edge and Firefox on the desktop, this seems to work fine. On Chrome, in developer mode, when I run under emulation mode for mobile devices, it works too.

But when I test on an iPhone with iOS 12, not all of the images render. It happens on both Safari and Chrome. A few of the larger images are displayed as gray areas. I hadn't seen that before during development. When I change the element back to just the jpg , it renders OK:

<img src="images/gallery/urban.jpg" alt="Alt Title" style="">

I'm not sure the best way to fix this. Maybe there is something wrong with the markup. Or maybe I should consider it a bug and try to work around it by forcing jpg/png images when the operating system is iOS? (by using CSS or HTML or Javascript?) But the problem seems to be affecting only certain larger images. It is a bit of a hassle to have to manually test to determine which images should be "picture" and which should be just "img".

like image 565
George Hernando Avatar asked May 01 '19 17:05

George Hernando


People also ask

Does iOS support WebP image format?

WebP images are supported in Chrome, Firefox and Microsoft Edge browsers, but has been notably absent from both iOS and macOS Safari.

Does iOS Safari support WebP?

However, Safari version 14, released September 2020, started to support WebP. WebP image format was already supported by Chrome (and its Chromium derivatives), the world's most popular mobile browser, starting back in 2014 with version 32.

How do I open a WebP file in iOS?

If you are an Android, iOS, or Chrome OS user, you can open WEBP files with Google Photos. You can also upload WebP images to Google Photos to view them with the web application.

Why does WebP not work on Safari?

The support for WebP image format is available in Safari 14, and it is not possible to support webp images in older Safari versions. You cannot just change the webp files to make them to work on incompatible Safari versions that do not support it. It will not work.


1 Answers

WebP was designed by Google for use in Google Chrome. Unfortunately, WebP is not supported in Apple's Safari web browser.

https://discussions.apple.com/thread/250073758

Only starting with iOS 14 (released end of September 2020), Safari on iOS supports webp.

like image 148
sortofme Avatar answered Nov 15 '22 08:11

sortofme