Skip to content

Instantly share code, notes, and snippets.

@Fastidious
Forked from tsertkov/nginx_image_filter.conf
Last active August 26, 2015 18:37
Show Gist options
  • Save Fastidious/c9aa898f8e09dbf0f351 to your computer and use it in GitHub Desktop.
Save Fastidious/c9aa898f8e09dbf0f351 to your computer and use it in GitHub Desktop.
On the fly image resizing with image_filter
# On the fly resizing of images inside /images/*/
# based on query string "width" and "height" parameters
location ~ /images/(.+)/ {
set $width -;
set $height -;
set $entity $1;
if ($arg_width) {
set $width $arg_width;
}
if ($arg_height) {
set $height $arg_height;
}
image_filter resize $width $height;
image_filter_buffer 128M;
random_index on;
if (!-e $request_filename) {
rewrite ^ /images/$entity/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment