Try_files and filter modules

Hello,
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 {
internal;
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.

rr

On Monday 13 February 2012 16:46:55 Reinis R. wrote:

}

The crop filter is never applied.
[…]

Probably, because $uri and $1/medium_$2 doesn’t exist or
smaller than your crop.

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

wbr, Valentin V. Bartenev

 try_files $uri $1/medium_$2 $1/large_$2 =404;

Hmm, thx the ‘= 404’ is all that I missed.

p.s. the files indeed didn’t exist (expected) but the request always
returned the source/original file (without cropping it), but
now with the additional 404 it works nicely.

rr

On Monday 13 February 2012 17:55:35 Reinis R. wrote:
[…]

p.s. the files indeed didn’t exist (expected) but the request always
returned the source/original file (without cropping it), but now with the
additional 404 it works nicely.

It was handled by another location. The last part in the try_files
directive
always does internal redirect (to $1/large_$2 in your case, so then it
didn’t
catch by “location ~ (.)/small_(.)”).

wbr, Valentin V. Bartenev

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs