For unknown reasons, having ListImagesForBiblio return undef
when there are no images still results in a variable being passed
to the template which evaluates as true, with a size of 1.
This patch alters ListImagesForBiblio to remove the "return undef"
condition, allowing the template to evaluate images as false
and show no tab.
To test, turn on local cover images and view records in the OPAC
which do and do not have cover images attached. Images should
display as expected when present, and no images tab should appear
on records which have none.
Signed-off-by: Melia Meggs <melia@test.bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
my $query = 'SELECT imagenumber FROM biblioimages WHERE biblionumber = ?';
my $sth = $dbh->prepare($query);
$sth->execute($biblionumber);
- warn "Database error!" if $sth->errstr;
- if ( !$sth->errstr && $sth->rows > 0 ) {
- while ( my $row = $sth->fetchrow_hashref ) {
- push @imagenumbers, $row->{'imagenumber'};
- }
- return @imagenumbers;
- }
- else {
- return undef;
+ while ( my $row = $sth->fetchrow_hashref ) {
+ push @imagenumbers, $row->{'imagenumber'};
}
+ return @imagenumbers;
}
=head2 DelImage
</li>
[% END %]
-[% IF ( OPACLocalCoverImages ) %][% IF ( localimages ) %]
+[% IF ( OPACLocalCoverImages && localimages.size ) %]
<li id="tab_images"><a href="#images">Images</a></li>
-[% END %][% END %]
+[% END %]
</ul>
[% IF ( serialcollection ) %]
</table>
</div>[% END %][% END %]
-[% IF ( OPACLocalCoverImages ) %]
+[% IF ( OPACLocalCoverImages && localimages.size ) %]
<div id="images">
<p>Click on an image to view it in the image viewer</p>
[% FOREACH image IN localimages %]