|
Lines 25-39
Link Here
|
| 25 |
|
25 |
|
| 26 |
use Modern::Perl; |
26 |
use Modern::Perl; |
| 27 |
|
27 |
|
| 28 |
use CGI qw ( -utf8 ); #qw(:standard escapeHTML); |
28 |
use CGI qw ( -utf8 ); |
| 29 |
use C4::Context; |
29 |
use C4::Context; |
| 30 |
use Koha::CoverImages; |
|
|
| 31 |
use Koha::Biblios; |
30 |
use Koha::Biblios; |
| 32 |
use Koha::Exceptions; |
31 |
use Koha::CoverImages; |
| 33 |
|
32 |
|
| 34 |
$| = 1; |
33 |
$| = 1; |
| 35 |
|
34 |
|
| 36 |
my $data = CGI->new; |
35 |
my $input = CGI->new; |
| 37 |
my $imagenumber; |
36 |
my $imagenumber; |
| 38 |
|
37 |
|
| 39 |
=head1 NAME |
38 |
=head1 NAME |
|
Lines 60-74
imagenumber, a random image is selected.
Link Here
|
| 60 |
|
59 |
|
| 61 |
my ( $image ); |
60 |
my ( $image ); |
| 62 |
if ( C4::Context->preference("LocalCoverImages") ) { |
61 |
if ( C4::Context->preference("LocalCoverImages") ) { |
| 63 |
my $imagenumber = $data->param('imagenumber'); |
62 |
my $imagenumber = $input->param('imagenumber'); |
| 64 |
my $biblionumber = $data->param('biblionumber'); |
63 |
my $biblionumber = $input->param('biblionumber'); |
| 65 |
if ( defined $imagenumber ) { |
64 |
if ( defined $imagenumber ) { |
| 66 |
$imagenumber = $data->param('imagenumber'); |
65 |
$imagenumber = $input->param('imagenumber'); |
| 67 |
$image = Koha::CoverImages->find($imagenumber); |
66 |
$image = Koha::CoverImages->find($imagenumber); |
|
|
67 |
unless ($image) { |
| 68 |
print $input->redirect("/cgi-bin/koha/errors/404.pl"); |
| 69 |
exit; |
| 70 |
} |
| 68 |
} |
71 |
} |
| 69 |
elsif ( defined $biblionumber ) { |
72 |
elsif ( defined $biblionumber ) { |
| 70 |
my $biblio = Koha::Biblios->find($biblionumber); |
73 |
my $biblio = Koha::Biblios->find($biblionumber); |
| 71 |
Koha::Exceptions::ObjectNotFound->throw( 'No bibliographic record for biblionumber ' . $biblionumber ) unless $biblio; |
74 |
unless ($biblio) { |
|
|
75 |
print $input->redirect("/cgi-bin/koha/errors/404.pl"); |
| 76 |
exit; |
| 77 |
} |
| 72 |
my $cover_images = $biblio->cover_images; |
78 |
my $cover_images = $biblio->cover_images; |
| 73 |
if ( $cover_images->count ) { |
79 |
if ( $cover_images->count ) { |
| 74 |
$image = $cover_images->next; |
80 |
$image = $cover_images->next; |
|
Lines 79-89
if ( C4::Context->preference("LocalCoverImages") ) {
Link Here
|
| 79 |
$image ||= Koha::CoverImages->no_image; |
85 |
$image ||= Koha::CoverImages->no_image; |
| 80 |
|
86 |
|
| 81 |
my $image_data = |
87 |
my $image_data = |
| 82 |
$data->param('thumbnail') |
88 |
$input->param('thumbnail') |
| 83 |
? $image->thumbnail |
89 |
? $image->thumbnail |
| 84 |
: $image->imagefile; |
90 |
: $image->imagefile; |
| 85 |
|
91 |
|
| 86 |
print $data->header( |
92 |
print $input->header( |
| 87 |
-type => $image->mimetype, |
93 |
-type => $image->mimetype, |
| 88 |
-expires => '+30m', |
94 |
-expires => '+30m', |
| 89 |
-Content_Length => length($image_data) |
95 |
-Content_Length => length($image_data) |