3 # based on patronimage.pl
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 use CGI; #qw(:standard escapeHTML);
38 opac-image.pl - Script for retrieving and formatting local cover images for display
42 <img src="opac-image.pl?imagenumber=X" />
43 <img src="opac-image.pl?biblionumber=X" />
44 <img src="opac-image.pl?imagenumber=X&thumbnail=1" />
45 <img src="opac-image.pl?biblionumber=X&thumbnail=1" />
49 This script, when called from within HTML and passed a valid imagenumber or
50 biblionumber, will retrieve the image data associated with that biblionumber
51 if one exists, format it in proper HTML format and pass it back to be displayed.
52 If the parameter thumbnail has been provided, a thumbnail will be returned
53 rather than the full-size image. When a biblionumber is provided rather than an
54 imagenumber, a random image is selected.
58 if (defined $data->param('imagenumber')) {
59 $imagenumber = $data->param('imagenumber');
60 } elsif (defined $data->param('biblionumber')) {
61 my @imagenumbers = ListImagesForBiblio($data->param('biblionumber'));
63 $imagenumber = $imagenumbers[0];
65 warn "No images for this biblio" if $DEBUG;
73 warn "imagenumber passed in: $imagenumber" if $DEBUG;
74 my $imagedata = RetrieveImage($imagenumber);
76 error() unless $imagedata;
80 if ($data->param('thumbnail')) {
81 $image = $imagedata->{'thumbnail'};
83 $image = $imagedata->{'imagefile'};
85 print $data->header (-type => $imagedata->{'mimetype'}, -'Cache-Control' => 'no-store', -expires => 'now', -Content_Length => length ($image)), $image;
88 warn "No image exists for $imagenumber" if $DEBUG;
98 print $data->header ( -status=> '404', -expires => 'now' );
104 Chris Nighswonger cnighswonger <at> foundations <dot> edu
106 modified for local cover images by Koustubha Kale kmkale <at> anantcorp <dot> com