litespeedtech / litespeedtech/lscache_wp

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

Open
#347 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.