Bug 28178: Display the correct image in the image viewer

When there are several images attached to a bibliographic record, one can click
an image and see it in the image viewer. But the first image is always displayed.

Test plan:
0. Turn on LocalCoverImages and AllowMultipleCovers
1. Attach at least two images to a bibliographic record
2. Go to the detail page, click the "Images" tab and click the second
image.
=> With this patch applied you should see the image you selected

Sponsored-by: Gerhard Sondermann Dialog e.K. (presseplus.de, presseshop.at, presseshop.ch)

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-04-19 12:11:36 +02:00
parent ff849fadba
commit 3dc9855b46
2 changed files with 2 additions and 2 deletions

View file

@ -77,7 +77,7 @@ if ( C4::Context->preference("LocalCoverImages") ) {
$template->param(
LocalCoverImages => 1,
images => $images,
imagenumber => (@$images ? $images->[0]->imagenumber : undef),
imagenumber => ( $imagenumber || ( @$images ? $images->[0]->imagenumber : undef ) ),
);
}
$template->{VARS}->{'count'} = $itemcount;

View file

@ -83,7 +83,7 @@
[% FOREACH image IN images %]
<li id="imagenumber-[% image.imagenumber | html %]" data-itemnumber="[% image.itemnumber | html %]" data-biblionumber="[% image.biblionumber | html %]" class="thumbnail">
<a class="show_cover" data-coverimg="[% image.imagenumber | html %]" href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber | html %]&amp;imagenumber=[% image.imagenumber | html %]">
[% IF loop.first %]
[% IF image.imagenumber == imagenumber %]
<img class="selected" id="thumbnail_[% image.imagenumber | html %]" src="/cgi-bin/koha/catalogue/image.pl?imagenumber=[% image.imagenumber | html %]&amp;thumbnail=1" alt="Thumbnail" />
[% ELSE %]
<img id="thumbnail_[% image.imagenumber | html %]" src="/cgi-bin/koha/catalogue/image.pl?imagenumber=[% image.imagenumber | html %]&amp;thumbnail=1" alt="Thumbnail" />