Quantcast
Channel: Nginx Forum - Nginx Mailing List - English
Viewing all articles
Browse latest Browse all 7229

map directive using $default as origin (2 replies)

$
0
0
Hello!

I am using module small_light
(https://github.com/cubicdaiya/ngx_small_light), since the module can't
detect which browser can process webp transformation, I creating a
simple directive on nginx to detect chrome and opera only and fallback
the rest to jpeg/jpg.

But, if the origin is not jpg (eg: png or gif), the directive transform
it into jpg.

The snippet looks like :

map $http_user_agent $img_mode {
$default jpg;
~*chrome webp;
~*opera webp;
}

.... snip ...
location ~ \.(jpe?g|png|gif|webp)$ {
root /usr/share/nginx/html;
small_light on;
small_light_getparam_mode on;
rewrite (?<capt>.*) $capt?$args&of=$img_mode break;
}
.... snip ...

Is it possible to give the $default value came from the origin file(s)?
So the nginx didn't process png/gif into jpg if using firefox. And will
process anything into webp if using Opera/Google Chrome.

Many helps are appreciated.
Thank you :)

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Viewing all articles
Browse latest Browse all 7229

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>