[Templates] PATCH Image plugin fails with Image::Size
Axel Gerstmair
Axel Gerstmair <anthill@web.de>
Wed, 23 Apr 2003 21:59:32 +0200
Hi all,
while testing the current developer release of TT, version 2.09a, I
stumbled upon an error with the Image plugin. The error occurs only if
you are using Image::Size and don't have Image::Info installed. Below
is a patch that fixes the problem.
Best regards,
Axel
Index: Image.pm
===================================================================
RCS file: /template-toolkit/Template2/lib/Template/Plugin/Image.pm,v
retrieving revision 1.6
diff -u -w -b -r1.6 Image.pm
--- Image.pm 2003/04/23 15:14:08 1.6
+++ Image.pm 2003/04/23 19:42:35
@@ -43,7 +43,12 @@
my @stuff = Image::Size::imgsize($file);
return { "width" => $stuff[0],
"height" => $stuff[1],
- "error" => $stuff[2]
+ "error" =>
+ # imgsize returns either a three letter file type
+ # or an error message as third value
+ (defined($stuff[2]) && length($stuff[2]) > 3
+ ? $stuff[2]
+ : undef),
};
}
}