Search code examples
iosswiftwebp

UIWebview/WKWebivew WebP support


I am trying to support loading html with webp image links served up to me from an API. Here is a fake sample of html:

let theBody = "<img src=\"https://www.gstatic.com/webp/gallery3/2_webp_ll.webp\">"
webView.loadHTMLString(theBody, baseURL: nil)

However, this just load a placeholder:

enter image description here

Sometimes I might even get image strings with a .png format but the webview's GET request shows the content type is still webp

how can I get the UIWebView/WKWebView to support webp?


Solution

  • UIWebView and WKWebView (and for that matter Safari and SFSafariViewController) do not support webp.

    https://caniuse.com/#search=webp

    There's nothing you can do about this until Apple adds support.