try_files and filter modules

Reinis Rozitis r at
Mon Feb 13 12:46:55 UTC 2012

is there a reason (or workaround) why try_files doesn't work with filter modules (in my case its image_filter)?

For example:

location ~ (.*)/small_(.*) {
      try_files $uri $1/medium_$2 $1/large_$2;
      image_filter   crop  175 175;

The crop filter is never applied.

The idea is to generate the thumbnail in a chain fashion - first detect if there is already an image in needed size/name then try to 
resize it from medium sized version and if it doesn't exist use the original source file.

I can rewrite it to something like:

location ~ /small_ {
        try_files $uri @smallresize;

location @smallresize {
        rewrite (.*)/small_(.*) $1/large_$2 break;
        image_filter   crop  175 175;

But obviously it misses the "medium" step. Also wouldn't like to use multiple 'if's.

p.s. it also seems that try_files doesn't work with more than one @named location - every except the last one is checked ( stat() ) 
as physical files.


More information about the nginx mailing list