Created
December 18, 2013 10:20
-
-
Save korotovsky/8020127 to your computer and use it in GitHub Desktop.
Nginx locations for rewrite ordinary images to retina verstion with falback to ordinary if retina version is not present
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### | |
# Retina images handler | |
### | |
if ($http_cookie ~* "isRetina=1" ) { | |
set $isRetina "retina"; | |
} | |
location ~ ^/bundles/(.*)-retina\.png { | |
try_files /bundles/$1-retina.png @retinaFallback; | |
} | |
location ~ ^/bundles/(.*)\.png$ { | |
if ($isRetina = "retina") { | |
rewrite ^/bundles/(.*).png$ /bundles/$1-retina.png last; | |
} | |
} | |
location @retinaFallback { | |
rewrite ^/bundles/(.*)-retina.png$ /bundles/$1.png break; | |
} | |
## | |
# End retina handler | |
## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment