<%def .image>\
<%perl>
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)); }
+ if (defined $scale) {
+ my $img = TrivGal::Image->new($path);
+ $m->redirect($img->scale($scale));
+ }
+ my $real = join_paths $IMGROOT, $path;
my $url = join_paths $IMGURL, $path;
my $realdir = join_paths $IMGROOT, $dir;
my $urldir = join_paths $SCRIPTURL, $dir;
my ($dd, $ff, $ii) = listdir $realdir;
- my $vw = $img->scale("view");
+ my @thumbsz = qw{smallthumb medthumb bigthumb};
+ my %tn;
+ my $vw;
my $fi = undef;
- FILE: for (my $i = 0; $i < @$ff; $i++)
- { if ($ff->[$i]->name eq "$base$ext") { $fi = $i; last FILE; } }
+ FILE: for (my $i = 0; $i < @$ff; $i++) {
+ my $f = $ff->[$i];
+ my $img = TrivGal::Image->new(join_paths $dir, $f->name);
+ for my $sz (@thumbsz) { $tn{$f->name}{$sz} = $img->scale($sz); }
+ if ($ff->[$i]->name eq "$base$ext")
+ { $fi = $i; $vw = $img->scale("view"); }
+ }
defined $fi or die "image not found in its folder?";
my $this = $ff->[$fi];
% }
</div>
%
-% my %img = map { $_ => TrivGal::Image->new($dir . "/" . $_->name) } @$ff;
% for my $size (qw{smallthumb medthumb bigthumb}) {
<div class="thumbstrip <% $size %>">
% for my $f (@$ff) {
<& .thumbnail, target => $f->name,
- img => $img{$f}->scale($size), size => $size,
+ tn => $tn{$f->name}{$size}, size => $size,
caption => $m->interp->apply_escapes($f->name, "h"),
focus => $f eq $this &>\
% }