Showing webp images on custom places in the template




Wordpress LScache Plugin: Showing webp images on custom places in the template

Last Updated on: Wed, 15 Apr 2026 00:00:02
Hi, we have some images of are posts in our template that are not shown as webp while browsing with google chrome.These images are shown with our own plugins on different places in our template. (Latest posts,special posts and?) How can we change the code in our template to show the webp version of the images while browsing with google chrome like the litespeed plugin does? It will be automatically replaced if its like or and set correctly in config WebP Attribute To Replace. What is the image code format in your template? Hi, on of our codes on the front page is like this to display the images of our posts: alt= title= align=middle width=300 height=300 > Is there any function in your plugin to activate this feature that we can add to our own script? Please give the full snippet of that code. Cant see the full image attribute as you didnt paste it. Basically, you dont need to do anything, our plugin will replace images to WebP in the whole content buffer before output (if the WebP file exists). Do you want to replace manually? alt= title= align=middle width=300 height=300 > this is all Ive put on my page. the $cookedpost variable contains the custom post type other plugin build for my use case scenario. Actually I wanned to replace the image manually and Im fine with that (adding .webp to end of the url) but theres a support issue of webp on other browsers. so I want to do it the same way litespeed plugin do and detect the browser and put the .jpeg extension if its non-chrome browser. I was wondering if there was a function like litespeed_image( $cookedPost->image ) so it handle it like the rest of the images it is doing. thanks for your good support This is a basic format of img code usage. You dont have to anything. As long as the image is optimized with webp file, it will be replaced by our plugin before output to browser. I believe you should be able to see the WebP version if you try it.



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



Reference