# atec-webp NGINX rules # Place this inside your NGINX server block, or include it manually location ~* ^/wp-content/uploads/(.+)\.(jpe?g|png|gif|bmp)$ { set $img_uri $uri; # 1. Serve .Xwebp.webp if it exists set $webp_x "$img_uri.Xwebp.webp"; if (-f $document_root$webp_x) { add_header Vary "Accept"; add_header Content-Type image/webp; return 200 $webp_x; } # 2. Serve .webp if it exists set $webp "$img_uri.webp"; if (-f $document_root$webp) { add_header Vary "Accept"; add_header Content-Type image/webp; return 200 $webp; } # 3. Fallback to dynamic converter rewrite ^/wp-content/uploads/(.+\.(jpe?g|png|gif|bmp))$ /wp-content/plugins/atec-webp/img2webp.php?src=$1 last; }