From 268918076bab2b84133e88c7dd7aefefeb3fc673 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 20 Apr 2021 14:41:34 +0200 Subject: [PATCH] Bug 28180: Reintroduce and adjust OpenLibrary 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) --- .../opac-tmpl/bootstrap/en/modules/opac-detail.tt | 13 +++++++++++++ koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js | 14 +++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt index ad74cb647c..0433eb2804 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -121,6 +121,13 @@ [% END %] + [% IF OpenLibraryCovers %] +
+
+
Image from OpenLibrary
+
+ [% END %] + [% IF Koha.Preference('OPACCustomCoverImages') && Koha.Preference('CustomCoverImagesURL') %] [% SET custom_cover_image_url = biblio.custom_cover_image_url %] [% IF custom_cover_image_url %] @@ -1662,6 +1669,10 @@ 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(){ @@ -1703,6 +1714,8 @@ lightbox_descriptions.push("Image from Syndetics") } else if( div.attr("id") == "googlejacket-coverimg" ){ lightbox_descriptions.push(_("Image from Google Jacket (see the original image)").format($(img).data('link'))); + } else if( div.attr("id") == "openlibrary-coverimg" ){ + lightbox_descriptions.push(_("Image from OpenLibrary (see the original image)").format($(img).data('link'))); } else if( div.attr("id") == "coce-coverimg" ){ // Identify which service's image is being loaded by Coce var coce_description; diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js b/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js index 9ca62cb17b..8537165e72 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/openlibrary.js @@ -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); -- 2.20.1