Adding code to default to patron-blank.png if no image exists in the
authorChris Nighswonger <cnighswonger@foundations.edu>
Mon, 25 Feb 2008 20:30:18 +0000 (09:30 +1300)
committerJoshua Ferraro <jmf@liblime.com>
Wed, 27 Feb 2008 15:02:16 +0000 (09:02 -0600)
Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
members/patronimage.pl

index 84ce9f4..bc9b14f 100755 (executable)
@@ -64,8 +64,15 @@ if ($dberror) {
 # NOTE: Never dump the contents of $imagedata->{'patronimage'} via a warn to a log or nasty
 # things will result... you have been warned!
 
-print header (-type => $imagedata->{'mimetype'}, -Content_Length => length ($imagedata->{'imagefile'})), 
-            $imagedata->{'imagefile'};
+if ($imagedata) {
+    print header (-type => $imagedata->{'mimetype'}, -Content_Length => length ($imagedata->{'imagefile'})), $imagedata->{'imagefile'};
+    exit;
+} else {
+    warn "No image exists for $cardnumber" if $DEBUG;
+    my $urlbase = url(-base => 1 -rewrite => 1);
+    warn "URL base: $urlbase" if $DEBUG;
+    print redirect (-uri => "$urlbase/intranet-tmpl/prog/img/patron-blank.png");
+}
 
 exit;