Bug 28180: Reintroduce and adjust OpenLibrary
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 20 Apr 2021 12:41:34 +0000 (14:41 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 21 Oct 2021 10:24:04 +0000 (12:24 +0200)
1. Turn on OpenLibraryCovers
2. Display the cover images in the gallery

Sponsored-by: Gerhard Sondermann Dialog e.K. (presseplus.de, presseshop.at, presseshop.ch)
Signed-off-by: Rasmus Leißner <rasmus.leissner@solutions-factory.de>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js

index 54e50d1..6887dec 100644 (file)
                                 </div>
                             [% END %]
 
+                            [% IF OpenLibraryCovers %]
+                                <div class="cover-image" id="openlibrary-coverimg">
+                                    <div title="[% img_title | html %]" class="[% normalized_isbn | html %]" id="openlibrary-thumbnail-preview" data-use-data-link="1"></div>
+                                    <div class="hint">Image from OpenLibrary</div>
+                                </div>
+                            [% END %]
+
                             [% IF Koha.Preference('OPACCustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %]
                                 [% SET custom_cover_image_url = biblio.custom_cover_image_url %]
                                 [% IF custom_cover_image_url %]
                 KOHA.coce.getURL('[% Koha.Preference('CoceHost') | html %]', '[% Koha.Preference('CoceProviders') | html %]',[% covernewwindow | html %]);
             [% END %]
 
+            [% IF OpenLibraryCovers %]
+                KOHA.OpenLibrary.GetCoverFromIsbn();
+            [% END %]
+
         function verify_images() {
             // Loop over each container in the template which contains covers
             $(".cover-slider").each(function(){
                                 lightbox_descriptions.push("Image from Syndetics")
                             } else if( div.attr("id") == "googlejacket-coverimg" ){
                                 lightbox_descriptions.push(_("Image from Google Jacket (<a href='%s'>see the original image</a>)").format($(img).data('link')));
+                            } else if( div.attr("id") == "openlibrary-coverimg" ){
+                                lightbox_descriptions.push(_("Image from OpenLibrary (<a href='%s'>see the original image</a>)").format($(img).data('link')));
                             } else if( div.attr("id") == "coce-coverimg" ){
                                 // Identify which service's image is being loaded by Coce
                                 var coce_description;
index 9ca62cb..8537165 100644 (file)
@@ -40,15 +40,19 @@ KOHA.OpenLibrary = new function() {
             var book = booksInfo[id];
             var isbn = id.substring(5);
             $("[id^=openlibrary-thumbnail]."+isbn).each(function() {
-                var is_opacdetail = /openlibrary-thumbnail-preview/.exec($(this).attr("id"));
                 var a = document.createElement("a");
                 a.href = booksInfo.url;
                 if (book.cover) {
-                    var img = document.createElement("img");
-                    if (is_opacdetail) {
-                        img.src = book.cover.medium;
-                        $(this).empty().append(img);
+                    if ( $(this).data('use-data-link') ) {
+                         var a = document.createElement("a");
+                         a.href = book.cover.large;
+                         var img = document.createElement("img");
+                         img.src = book.cover.medium;
+                         img.setAttribute('data-link', book.cover.large);
+                         a.append(img)
+                         $(this).empty().append(a);
                     } else {
+                        var img = document.createElement("img");
                         img.src = book.cover.medium;
                         img.height = '110';
                         $(this).append(img);