View | Details | Raw Unified | Return to bug 26145
Collapse All | Expand All

(-)a/C4/Images.pm (-1 / +1 lines)
Lines 113-119 sub RetrieveImage { Link Here
113
113
114
    my $dbh = C4::Context->dbh;
114
    my $dbh = C4::Context->dbh;
115
    my $query =
115
    my $query =
116
'SELECT imagenumber, mimetype, imagefile, thumbnail FROM biblioimages WHERE imagenumber = ?';
116
'SELECT biblionumber, itemnumber, imagenumber, mimetype, imagefile, thumbnail FROM biblioimages WHERE imagenumber = ?';
117
    my $sth = $dbh->prepare($query);
117
    my $sth = $dbh->prepare($query);
118
    $sth->execute($imagenumber);
118
    $sth->execute($imagenumber);
119
    my $imagedata = $sth->fetchrow_hashref;
119
    my $imagedata = $sth->fetchrow_hashref;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt (+13 lines)
Lines 1212-1217 Link Here
1212
    <table class="table table-bordered table-striped" id="[% table_id | html %]">
1212
    <table class="table table-bordered table-striped" id="[% table_id | html %]">
1213
        <thead>
1213
        <thead>
1214
            <tr>
1214
            <tr>
1215
                [% IF ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
1216
                    <th id="item_cover" data-colname="item_cover">Cover image</th>
1217
                [% END %]
1215
                [% IF ( item_level_itypes ) %]
1218
                [% IF ( item_level_itypes ) %]
1216
                    <th id="item_itemtype" data-colname="item_itemtype" class="itype">Item type</th>
1219
                    <th id="item_itemtype" data-colname="item_itemtype" class="itype">Item type</th>
1217
                [% END %]
1220
                [% END %]
Lines 1263-1268 Link Here
1263
                [% ELSE %]
1266
                [% ELSE %]
1264
                  <tr vocab="http://schema.org/" typeof="Offer">
1267
                  <tr vocab="http://schema.org/" typeof="Offer">
1265
                [% END %]
1268
                [% END %]
1269
1270
                [% IF ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %]
1271
                    <td class="cover">
1272
                        <div title="[% ITEM_RESULT.itemnumber | html %]" data-imagenumber="[% ITEM_RESULT.imagenumber | html %]" data-biblionumber="[% ITEM_RESULT.biblionumber %]" class="local-thumbnail-preview"></div>
1273
                    </td>
1274
                [% END %]
1275
1266
                [% IF ( item_level_itypes ) %]
1276
                [% IF ( item_level_itypes ) %]
1267
                    <td class="itype">
1277
                    <td class="itype">
1268
                        [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
1278
                        [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
Lines 1619-1624 Link Here
1619
            [% END %]
1629
            [% END %]
1620
            [% IF OPACLocalCoverImages %]
1630
            [% IF OPACLocalCoverImages %]
1621
                KOHA.LocalCover.GetCoverFromBibnumber(true);
1631
                KOHA.LocalCover.GetCoverFromBibnumber(true);
1632
                [% IF itemloop_has_images OR oheritemloop_has_images %]
1633
                    KOHA.LocalCover.GetCoverFromItemnumber(true);
1634
                [% END %]
1622
            [% END %]
1635
            [% END %]
1623
            [% IF ( NovelistSelectProfile && ( normalized_isbn || normalized_upc ) ) %]
1636
            [% IF ( NovelistSelectProfile && ( normalized_isbn || normalized_upc ) ) %]
1624
                novSelect.loadContentForQuery(
1637
                novSelect.loadContentForQuery(
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/localcovers.js (-1 / +36 lines)
Lines 49-53 KOHA.LocalCover = { Link Here
49
                    }
49
                    }
50
                })
50
                })
51
        });
51
        });
52
    }
52
    },
53
    GetCoverFromItemnumber: function(uselink) {
54
        $("div[class^=local-thumbnail],span[class^=local-thumbnail]").each(function(i) {
55
            var mydiv = this;
56
            var message = document.createElement("span");
57
            var imagenumber  = $(mydiv).data("imagenumber");
58
            var biblionumber = $(mydiv).data("biblionumber");
59
            $(message).attr("class","no-image");
60
            $(message).html(NO_LOCAL_JACKET);
61
            $(mydiv).parent().find('.no-image').remove();
62
            $(mydiv).append(message);
63
            var img = $("<img />").attr('src',
64
                '/cgi-bin/koha/opac-image.pl?thumbnail=1&imagenumber=' + imagenumber)
65
                .load(function () {
66
                    this.setAttribute("class", "thumbnail");
67
                    if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
68
                        //IE HACK
69
                        try {
70
                            $(mydiv).append(img);
71
                            $(mydiv).children('.no-image').remove();
72
                        }
73
                        catch(err){
74
                        };
75
                    } else if (this.width > 1) { // don't show the silly 1px "no image" img
76
                        if (uselink) {
77
                            var a = $("<a />").attr('href', '/cgi-bin/koha/opac-imageviewer.pl?imagenumber=' + imagenumber + '&biblionumber=' + biblionumber);
78
                            $(a).append(img);
79
                            $(mydiv).empty().append(a);
80
                        } else {
81
                            $(mydiv).empty().append(img);
82
                        }
83
                        $(mydiv).children('.no-image').remove();
84
                    }
85
                })
86
        });
87
    },
53
};
88
};
(-)a/opac/opac-detail.pl (+14 lines)
Lines 709-714 if ( C4::Context->preference('OPACAcquisitionDetails' ) ) { Link Here
709
}
709
}
710
710
711
my $allow_onshelf_holds;
711
my $allow_onshelf_holds;
712
my ( $itemloop_has_images, $otheritemloop_has_images );
712
if ( not $viewallitems and @items > $max_items_to_display ) {
713
if ( not $viewallitems and @items > $max_items_to_display ) {
713
    $template->param(
714
    $template->param(
714
        too_many_items => 1,
715
        too_many_items => 1,
Lines 762-776 if ( not $viewallitems and @items > $max_items_to_display ) { Link Here
762
          if grep { $_ eq $itm->{itemnumber} } @itemnumbers_on_order;
763
          if grep { $_ eq $itm->{itemnumber} } @itemnumbers_on_order;
763
    }
764
    }
764
765
766
    if ( C4::Context->preference("OPACLocalCoverImages") == 1 ) {
767
        $itm->{imagenumber} =
768
          C4::Images::GetImageForItem( $itm->{itemnumber} );
769
    }
770
765
    my $itembranch = $itm->{$separatebranch};
771
    my $itembranch = $itm->{$separatebranch};
766
    if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
772
    if ($currentbranch and C4::Context->preference('OpacSeparateHoldings')) {
767
        if ($itembranch and $itembranch eq $currentbranch) {
773
        if ($itembranch and $itembranch eq $currentbranch) {
768
            push @itemloop, $itm;
774
            push @itemloop, $itm;
775
            $itemloop_has_images++ if $itm->{imagenumber};
769
        } else {
776
        } else {
770
            push @otheritemloop, $itm;
777
            push @otheritemloop, $itm;
778
            $otheritemloop_has_images++ if $itm->{imagenumber};
771
        }
779
        }
772
    } else {
780
    } else {
773
        push @itemloop, $itm;
781
        push @itemloop, $itm;
782
        $itemloop_has_images++ if $itm->{imagenumber};
774
    }
783
    }
775
  }
784
  }
776
}
785
}
Lines 779-784 if( $allow_onshelf_holds || CountItemsIssued($biblionumber) || $biblio->has_item Link Here
779
    $template->param( ReservableItems => 1 );
788
    $template->param( ReservableItems => 1 );
780
}
789
}
781
790
791
$template->param(
792
    itemloop_has_images      => $itemloop_has_images,
793
    otheritemloop_has_images => $otheritemloop_has_images,
794
);
795
782
# Display only one tab if one items list is empty
796
# Display only one tab if one items list is empty
783
if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
797
if (scalar(@itemloop) == 0 || scalar(@otheritemloop) == 0) {
784
    $template->param(SeparateHoldings => 0);
798
    $template->param(SeparateHoldings => 0);
(-)a/opac/opac-imageviewer.pl (-6 / +14 lines)
Lines 26-31 use C4::Output; Link Here
26
use C4::Images;
26
use C4::Images;
27
27
28
use Koha::Biblios;
28
use Koha::Biblios;
29
use Koha::Items;
29
30
30
my $query = new CGI;
31
my $query = new CGI;
31
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
32
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
Lines 39-52 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
39
40
40
my $biblionumber = $query->param('biblionumber') || $query->param('bib');
41
my $biblionumber = $query->param('biblionumber') || $query->param('bib');
41
my $imagenumber = $query->param('imagenumber');
42
my $imagenumber = $query->param('imagenumber');
43
unless ( $biblionumber ) {
44
    # Retrieving the biblio from the imagenumber
45
    my $image = C4::Images::RetrieveImage($imagenumber);
46
    my $item  = Koha::Items->find($image->{itemnumber});
47
    $biblionumber = $item->biblionumber;
48
}
42
my $biblio = Koha::Biblios->find( $biblionumber );
49
my $biblio = Koha::Biblios->find( $biblionumber );
43
50
44
if ( C4::Context->preference("OPACLocalCoverImages") ) {
51
if ( C4::Context->preference("OPACLocalCoverImages") ) {
45
    my @images = ListImagesForBiblio($biblionumber);
52
    my @images = !$imagenumber ? ListImagesForBiblio($biblionumber) : ();
46
    $template->{VARS}->{'OPACLocalCoverImages'} = 1;
53
    $template->param(
47
    $template->{VARS}->{'images'}               = \@images;
54
        OPACLocalCoverImages => 1,
48
    $template->{VARS}->{'biblionumber'}         = $biblionumber;
55
        images               => \@images,
49
    $template->{VARS}->{'imagenumber'} = $imagenumber || $images[0] || '';
56
        biblionumber         => $biblionumber,
57
        imagenumber          => $imagenumber || $images[0] || '',
58
    );
50
}
59
}
51
60
52
$template->{VARS}->{'biblio'} = $biblio;
61
$template->{VARS}->{'biblio'} = $biblio;
53
- 

Return to bug 26145