webmreplace

This commit is contained in:
Steffen Illium
2023-12-24 12:57:08 +01:00
committed by Steffen Illium
parent 3432dc7f9f
commit 768443a951

View File

@ -21,8 +21,14 @@ server {
add_header Cache-Control "public, no-transform";
}
location ~* \.(?:png|jpe?g)(\?.+)?$ {
try_files $uri$webp_suffix $uri =404;
# Capture image path, without the file extension
map $uri $image {
~*^/(assets)/(.+)\.(jpe?g|png)$ /$1/$2;
}
location /assets {
add_header Vary Accept;
try_files $image$webp_suffix $uri =404;
}
error_page 404 /404.html;