From: Mark Wooding Date: Fri, 9 Jun 2023 21:12:00 +0000 (+0100) Subject: mason/dhandler: Add a `scale' parameter to images. X-Git-Url: https://git.distorted.org.uk/~mdw/tgal/commitdiff_plain/9601c4bb6178c613e096ac17d581790f25d5ec60 mason/dhandler: Add a `scale' parameter to images. Just ensures that a cached thumbnail of the requested size exists and redirects to it. Useful for references from other pages. --- diff --git a/mason/dhandler b/mason/dhandler index aca88bb..ef7044c 100755 --- a/mason/dhandler +++ b/mason/dhandler @@ -146,6 +146,9 @@ Failed to find ‘<% $path |h %>’. my ($dir, $base, $ext) = split_path $path; my $real = join_paths $IMGROOT, $path; my $img = TrivGal::Image->new($path); + + if (defined $scale) { $m->redirect($img->scale($scale)); } + my $url = join_paths $IMGURL, $path; my $realdir = join_paths $IMGROOT, $dir; my $urldir = join_paths $SCRIPTURL, $dir; @@ -215,6 +218,7 @@ Failed to find ‘<% $path |h %>’. % <%args> $path + $scale => undef %