rosell-dk / webp-express

Wordpress plugin for serving autogenerated WebP images instead of jpeg/png to browsers that supports WebP
GNU General Public License v3.0
221 stars 63 forks source link

On-demand WebP using WordOps #586

Open JPaulMora opened 1 year ago

JPaulMora commented 1 year ago

Hey, I'm using wordops (https://wordops.net) and I'm trying to setup on-demand webp generation with this

# try to load alternative image.png.webp before image.png
location /wp-content/uploads {
    location ~ \.(png|jpe?g)$ {
        add_header Vary "Accept-Encoding";
        more_set_headers 'Access-Control-Allow-Origin : *';
        more_set_headers  "Cache-Control : public, no-transform";
        access_log off;
        log_not_found off;
        expires max;
        try_files $uri$avif_suffix $uri$webp_suffix $uri =404;
    }
    location ~* ^/?(.+)\.(webp)$ {
        if (-f $request_filename) {
            rewrite ^/?(.+)\.(webp)$ /wp-content/plugins/webp-express/wod/webp-realizer.php?xdestination-rel=xwp-content/uploads/$1.$2&wp-content=wp-content last;
#            proxy_set_header X-DESTINATIONREL "wp-content/uploads/$1.$2";
#            proxy_set_header X-WPCONTENT "wp-content";
        }
    }

   location ~* \.(php|gz|log|zip|tar|rar|xz)$ {
        #Prevent Direct Access Of PHP Files & Backups from Web Browsers
        deny all;
    }
}

currently it's not working, any ideas on how to implement this?