litespeedtech / litespeedtech/lscache_wp
[Feature Request] Function to get the Webp related to an image
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 257
- Forks
- 123
- PR merge metrics
- No merged PRs in 30d
Description
[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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how get_attachment_by_id handles attachment IDs and URLs, then review the existing LiteSpeed WebP handling around file_exists checks. Done should be a documented function that returns the related WebP URL when it exists while preserving access to the original image as a fallback.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, wordpress
- Domain
- backend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100