lscache_wp icon indicating copy to clipboard operation
lscache_wp copied to clipboard

[Feature Request] Function to get the Webp related to an image

Open fredy31 opened this issue 3 years ago • 0 comments

[Created the issue on WP forums, but think its gonna be seen better by the devs here.]

Hello!

I’m using Litespeed on my website, but when I go get an image with get_attachment_by_id it gives me the png/jpg image.

I still want that, so I can get the fallback, but is there a function that I can call where I would pass the id of the attachment (or the attachment URL) and then it gives me back the webp of the image back (if it exists.)

Because right now my way of doing so is basically fumbling around with file_exists to check if the file + .webp exists, and if it does, load that image. But that is pretty server intensive and doesn’t seem to always work.

So is there a function that I can just give a image ID or URL and litespeed gives back the related webp url?

fredy31 avatar May 17 '21 14:05 fredy31