• Resolved David

    (@miladk)


    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?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Hai Zheng?

    (@hailite)

    It will be automatically replaced if it’s like <img src='xxx' /> or <xx xx='xx'> and set correctly in config WebP Attribute To Replace.

    What is the image code format in your template?

    • This reply was modified 6 years, 7 months ago by Hai Zheng?.
    Thread Starter David

    (@miladk)

    Hi, on of our codes on the front page is like this to display the images of our posts:

    <img src="<?php echo $cookedPost->image ?>"alt="<?php the_title() ?>" title="<?php the_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?

    • This reply was modified 6 years, 7 months ago by David.
    Plugin Support Hai Zheng?

    (@hailite)

    Please give the full snippet of that code. Can’t see the full image attribute as you didn’t paste it.

    Basically, you don’t 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?

    Thread Starter David

    (@miladk)

    
    <img src="<?php echo $cookedPost->image ?>" alt="<?php the_title() ?>" title="<?php the_title() ?>" align="middle"width="300"height="300">
    

    this is all I’ve 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 I’m fine with that (adding .webp to end of the url) but there’s 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 it’s 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 reply was modified 6 years, 7 months ago by David.
    Plugin Support Hai Zheng?

    (@hailite)

    This is a basic format of img code usage. You don’t 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.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Showing webp images on custom places in the template’ is closed to new replies.