Skip to content

Instantly share code, notes, and snippets.

@tsertkov
Last active August 29, 2015 14:02
Show Gist options
  • Save tsertkov/cab97e3b3536bc9973ac to your computer and use it in GitHub Desktop.
Save tsertkov/cab97e3b3536bc9973ac 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