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
229 stars 64 forks source link

installing webp express plugin on wordpress bedrock #407

Open pecedev opened 4 years ago

pecedev commented 4 years ago

Hi,

After installing the webp express plugin on wordpress bedrock i receive this error: "Failed migrating webp express options to 0.15.1. Probably you need to grant write permissions in your wp-content folder."

The problem is bedrock does not use wp-content folder and goes through site/web/app/uploads and not wp-content/uploads.

Is there any tutorial how to install webp express plugin in wordpress bedrock?

Thanks

bonakor commented 4 years ago

Hi. I managed to do it by adding this code to the nginx server conf:


# --------------------
location ~* ^/app/.*\.(png|jpe?g)$ {
    add_header Vary Accept;
    expires 365d;
}
location ~* ^/app/.*\.webp$ {
    expires 365d;
    if ($whattodo = AB) {
        add_header Vary Accept;
    }
}
if ($http_accept ~* "webp"){
    set $whattodo A;
}
if (-f $request_filename.webp) {
    set $whattodo  "${whattodo}B";
}
if ($whattodo = AB) {
    rewrite ^(.*) $1.webp last;
}
if ($whattodo = A) {
    rewrite ^/app/.*\.(jpe?g|png)$ /app/plugins/webp-express/wod/webp-on-demand.php?xsource=x$request_filename&wp-content=app break;
}
# ------------------- (WebP Express rules ends here)```