Bug 26145: Display the cover image at the OPAC
Sponsored-by: Gerhard Sondermann Dialog e.K. (presseplus.de, presseshop.at, presseshop.ch) Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
c3f2993bdb
commit
549d033cb1
|
|
@ -113,7 +113,7 @@ sub RetrieveImage {
|
|||
|
||||
my $dbh = C4::Context->dbh;
|
||||
my $query =
|
||||
'SELECT imagenumber, mimetype, imagefile, thumbnail FROM biblioimages WHERE imagenumber = ?';
|
||||
'SELECT biblionumber, itemnumber, imagenumber, mimetype, imagefile, thumbnail FROM biblioimages WHERE imagenumber = ?';
|
||||
my $sth = $dbh->prepare($query);
|
||||
$sth->execute($imagenumber);
|
||||
my $imagedata = $sth->fetchrow_hashref;
|
||||
|
|
|
|||
|
|
@ -1212,6 +1212,9 @@
|
|||
<table class="table table-bordered table-striped" id="[% table_id | html %]">
|
||||
<thead>
|
||||
<tr>
|
||||
[% IF ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
|
||||
<th id="item_cover" data-colname="item_cover">Cover image</th>
|
||||
[% END %]
|
||||
[% IF ( item_level_itypes ) %]
|
||||
<th id="item_itemtype" data-colname="item_itemtype" class="itype">Item type</th>
|
||||
[% END %]
|
||||
|
|
@ -1263,6 +1266,13 @@
|
|||
[% ELSE %]
|
||||
<tr vocab="http://schema.org/" typeof="Offer">
|
||||
[% END %]
|
||||
|
||||
[% IF ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
|
||||
<td class="cover">
|
||||
<div title="[% ITEM_RESULT.itemnumber | html %]" data-imagenumber="[% ITEM_RESULT.imagenumber | html %]" data-biblionumber="[% ITEM_RESULT.biblionumber %]" class="local-thumbnail-preview"></div>
|
||||
</td>
|
||||
[% END %]
|
||||
|
||||
[% IF ( item_level_itypes ) %]
|
||||
<td class="itype">
|
||||
[% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
|
||||
|
|
@ -1619,6 +1629,9 @@
|
|||
[% END %]
|
||||
[% IF OPACLocalCoverImages %]
|
||||
KOHA.LocalCover.GetCoverFromBibnumber(true);
|
||||
[% IF itemloop_has_images OR oheritemloop_has_images %]
|
||||
KOHA.LocalCover.GetCoverFromItemnumber(true);
|
||||
[% END %]
|
||||
[% END %]
|
||||
[% IF ( NovelistSelectProfile && ( normalized_isbn || normalized_upc ) ) %]
|
||||
novSelect.loadContentForQuery(
|
||||
|
|
|
|||
|
|
@ -49,5 +49,40 @@ KOHA.LocalCover = {
|
|||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
},
|
||||
GetCoverFromItemnumber: function(uselink) {
|
||||
$("div[class^=local-thumbnail],span[class^=local-thumbnail]").each(function(i) {
|
||||
var mydiv = this;
|
||||
var message = document.createElement("span");
|
||||
var imagenumber = $(mydiv).data("imagenumber");
|
||||
var biblionumber = $(mydiv).data("biblionumber");
|
||||
$(message).attr("class","no-image");
|
||||
$(message).html(NO_LOCAL_JACKET);
|
||||
$(mydiv).parent().find('.no-image').remove();
|
||||
$(mydiv).append(message);
|
||||
var img = $("<img />").attr('src',
|
||||
'/cgi-bin/koha/opac-image.pl?thumbnail=1&imagenumber=' + imagenumber)
|
||||
.load(function () {
|
||||
this.setAttribute("class", "thumbnail");
|
||||
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
|
||||
//IE HACK
|
||||
try {
|
||||
$(mydiv).append(img);
|
||||
$(mydiv).children('.no-image').remove();
|
||||
}
|
||||
catch(err){
|
||||
};
|
||||
} else if (this.width > 1) { // don't show the silly 1px "no image" img
|
||||
if (uselink) {
|
||||
var a = $("<a />").attr('href', '/cgi-bin/koha/opac-imageviewer.pl?imagenumber=' + imagenumber + '&biblionumber=' + biblionumber);
|
||||
$(a).append(img);
|
||||
$(mydiv).empty().append(a);
|
||||
} else {
|
||||
$(mydiv).empty().append(img);
|
||||
}
|
||||
$(mydiv).children('.no-image').remove();
|
||||
}
|
||||
})
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -709,6 +709,7 @@ if ( C4::Context->preference('OPACAcquisitionDetails' ) ) {
|
|||
}
|
||||
|
||||
my $allow_onshelf_holds;
|
||||
my ( $itemloop_has_images, $otheritemloop_has_images );
|
||||
if ( not $viewallitems and @items > $max_items_to_display ) {
|
||||
$template->param(
|
||||
too_many_items => 1,
|
||||
|
|
@ -762,15 +763,23 @@ if ( not $viewallitems and @items > $max_items_to_display ) {
|
|||
if grep { $_ eq $itm->{itemnumber} } @itemnumbers_on_order;
|
||||
}
|
||||
|
||||
if ( C4::Context->preference("OPACLocalCoverImages") == 1 ) {
|
||||
$itm->{imagenumber} =
|
||||
C4::Images::GetImageForItem( $itm->{itemnumber} );
|
||||
}
|
||||
|
||||
my $itembranch = $itm->{$separatebranch};
|
||||
if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
|
||||
if ($itembranch and $itembranch eq $currentbranch) {
|
||||
push @itemloop, $itm;
|
||||
$itemloop_has_images++ if $itm->{imagenumber};
|
||||
} else {
|
||||
push @otheritemloop, $itm;
|
||||
$otheritemloop_has_images++ if $itm->{imagenumber};
|
||||
}
|
||||
} else {
|
||||
push @itemloop, $itm;
|
||||
$itemloop_has_images++ if $itm->{imagenumber};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -779,6 +788,11 @@ if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_item
|
|||
$template->param( ReservableItems => 1 );
|
||||
}
|
||||
|
||||
$template->param(
|
||||
itemloop_has_images => $itemloop_has_images,
|
||||
otheritemloop_has_images => $otheritemloop_has_images,
|
||||
);
|
||||
|
||||
# Display only one tab if one items list is empty
|
||||
if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
|
||||
$template->param(SeparateHoldings => 0);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ use C4::Output;
|
|||
use C4::Images;
|
||||
|
||||
use Koha::Biblios;
|
||||
use Koha::Items;
|
||||
|
||||
my $query = new CGI;
|
||||
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
||||
|
|
@ -39,14 +40,22 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
|||
|
||||
my $biblionumber = $query->param('biblionumber') || $query->param('bib');
|
||||
my $imagenumber = $query->param('imagenumber');
|
||||
unless ( $biblionumber ) {
|
||||
# Retrieving the biblio from the imagenumber
|
||||
my $image = C4::Images::RetrieveImage($imagenumber);
|
||||
my $item = Koha::Items->find($image->{itemnumber});
|
||||
$biblionumber = $item->biblionumber;
|
||||
}
|
||||
my $biblio = Koha::Biblios->find( $biblionumber );
|
||||
|
||||
if ( C4::Context->preference("OPACLocalCoverImages") ) {
|
||||
my @images = ListImagesForBiblio($biblionumber);
|
||||
$template->{VARS}->{'OPACLocalCoverImages'} = 1;
|
||||
$template->{VARS}->{'images'} = \@images;
|
||||
$template->{VARS}->{'biblionumber'} = $biblionumber;
|
||||
$template->{VARS}->{'imagenumber'} = $imagenumber || $images[0] || '';
|
||||
my @images = !$imagenumber ? ListImagesForBiblio($biblionumber) : ();
|
||||
$template->param(
|
||||
OPACLocalCoverImages => 1,
|
||||
images => \@images,
|
||||
biblionumber => $biblionumber,
|
||||
imagenumber => $imagenumber || $images[0] || '',
|
||||
);
|
||||
}
|
||||
|
||||
$template->{VARS}->{'biblio'} = $biblio;
|
||||
|
|
|
|||
Loading…
Reference in New Issue