mason/dhandler: Add a `scale' parameter to images.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 9 Jun 2023 21:12:00 +0000 (22:12 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Fri, 9 Jun 2023 21:13:09 +0000 (22:13 +0100)
Just ensures that a cached thumbnail of the requested size exists and
redirects to it.  Useful for references from other pages.

mason/dhandler

index aca88bb..ef7044c 100755 (executable)
@@ -146,6 +146,9 @@ Failed to find &lsquo;<% $path |h %>&rsquo;.
        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 &lsquo;<% $path |h %>&rsquo;.
 %
 <%args>
        $path
+       $scale => undef
 </%args>
 </%def>
 %