How to retrieve webp images?




Wordpress LScache Plugin: How to retrieve webp images?

Last Updated on: Wed, 15 Apr 2026 00:00:02
How do I return webp images? E.g. I am using wp_get_attachment_image_srcset but the WEBP image is not being returned. Using wp_get_attachment_image_src doesnt retrieve it either. WebP dont have special hooks currently. You can append .webp to the image filename and detect if the file exists or not to retrieve it. Thanks. OK, @hailite how does it fallback to .jpg for unsupported browsers? Would be great if it would work out of the box, just like, say a CDN does. When I use wp_get_attachment_image_src to retrieve an image, the CDN url (if activated) is automatically retrieved. Also I noticed this setting: https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:configuration:media#webp_for_extra_srcset ? but in my srcset, there is no webp image. Also I tried appending the .webp image, but it is not found on the server. If I go to the media attachment, I see no button to generate or compress image. How can I compress the image, and generate webp as well? The image is old, so the cronjob should have finished by far. I see a lot of images that are not compressed, and Id like some button to compress them. There is no manual send request per image in Media list yet. Its in our todo. The way it fallback to .jpg for unsupported browser is bcos LiteSpeed cache supported vary to make multi copy of cache. Supported browser has a different cache copy than unsupported ones by vary.



LiteCache Rush: Speed comes from using less, not from doing it faster



Reference