• Resolved auludag

    (@auludag)


    Hi,
    thanks for plugin. I use shortpixel to convert images to webp. I only need a plugin which helps Google Chrome And Opera to find the webp images. Can i do this with your plugin? If yes, how?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author rosell.dk

    (@roselldk)

    Hi,

    I have looked a bit into shortpixel.
    I see it can be configured to generate webp images.
    I also see that they haven’t created a solution for actually serving the webp images to Chrome and Opera.

    What you need is rewrite rules, and that is something my plugin is able to generate. But currently it can not be configured to redirect to the images generated by shortpixel. I will consider adding this feature to my plugin. I’m however not sure it fits that well. The feature would fit better in the shortpixel plugin! Or perhaps in a little new plugin.

    Anyway, all you need to do to have your png and jpegs redirected to the webp-variants generated by shortpixel (for chrome and opera) is to add the following to your .htaccess file (located in your root):

    <ifModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTP_ACCEPT} image/webp
      RewriteCond %{REQUEST_URI}  (?i)(.*)(\.jpe?g|\.png)$
      RewriteCond %{DOCUMENT_ROOT}%1.webp -f
      RewriteRule (?i)(.*)(\.jpe?g|\.png)$ %1\.webp [L,T=image/webp,R]
    </IfModule>
    
    <IfModule mod_headers.c>
      Header append Vary Accept env=REDIRECT_accept
    </IfModule>
    
    AddType image/webp .webp

    If you want to know exacly what the rules does, you can go here for an explanation: https://www.digitalocean.com/community/tutorials/how-to-create-and-serve-webp-images-to-speed-up-your-website (see step 6)

    Thread Starter auludag

    (@auludag)

    Hi, thanks for detailed information. So can i assume yours is generates webp and also rewrite rules so Opera and Chrome Browser would see images on my site like webp.

    Since I don’t want to break some things, there are some webp images generated with Shortpixel. And if i use your plugin, it will convert images to webp again (i guess into a different directory) So it will serve from there. It will not touch to webp images inside image folder which is generated by Shortpixel.

    So i guess there are two alternatives then. If I want to use shortpixel for shrinking images and generate webp, i would be using htaccess snippet you shared above.

    Or I could leave webp image generation task to the services which are in your the settings of plugin? job, and other images shrinking task to Shortpixel, then your plugin would handle webp serving task automatically.

    Plugin Author rosell.dk

    (@roselldk)

    I could perhaps create a new “existing webp” converter, which looks for existing images in same folder as source.

    I could perhaps also create a “shortpixel” converter, which generates webp images by calling the shortpixel api. The benefit of this, would be to get the “on demand” functionality – that images are created when needed, and you dont need to do a bulk generate on a regular basis. And also, it would be able to get all images on the site, including theme images (shortpixel only optimizes images for the media library). However, the shortpixel API does not allow creating only the free webp image. It will only create the free webp image in conjunction with optimizing an image – and that costs a credit (https://shortpixel.com/api-docs). But still – a hundred free conversions a month is enough for many sites. And with WebP Express, it is not a problem if not all images are converted – as long as you set the fallback to “original”. So I guess a “shortpixel” converter for WebP Express would be useful to many.

    Plugin Author rosell.dk

    (@roselldk)

    The answer is “Yes” to your questions. I was assuming that you did not have a functional conversion method in WebP Express. If you do have that, you can use WebP Express in tandem.

    But it *seems* that you will get a better result with the snippet. I only ran a few tests, here is a case, where the tandem was not playing out that well:

    – shortpixel optimized a jpeg with quality 80 to a smaller jpeg – but with quality set to 92 (surprisingly)
    – webp express was able to detect the quality, and therefore used the max quality setting (which is 85)
    – As a result, the webp generated by webp express was larger than the webp generated by shortpixel.

    Thread Starter auludag

    (@auludag)

    Hi, yes it would help people who use Shortpixel since i assume they are many people who prefers Shortpixel, so Shortpixel is one of main players in WP ecosystem. And most people says it shrinks very well. And thanks to Appsumo deal, we overcame that 100 limit by buying subscriptions. But alas, there are lots of people who didn’t buy ShortPixel and look for webp images easy conversion and use. I can’t say which would be ideal approach for you though, improving current plugin (by adding a tick saying “use already converted webp images” like Litespeedcache did) or publishing a little helper plugin, since you would make a better decision.

    Thread Starter auludag

    (@auludag)

    Thanks, strangely that htaccess snippet didn’t help Chrome finding webp images. But i need to pursue this situation with theme provider and Shortpixel I assume since it has nothing to do with your plugin. Thank you very much for your help and sharing the links. This plugin will help webp conversion for my other sites that doesn’t use Shortpixel or alternative webp generator.

    Plugin Author rosell.dk

    (@roselldk)

    To quickly check if your .htaccess is being processed at all, you can add some random text in the top of the file. If .htaccess files are turned on, it should lay down you website! (and then you remove the random text again :))

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to configure’ is closed to new replies.