From 112168cfd5b59b6a18b6b4a72bbb475983165a32 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 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../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 54e50d1e42..6887dec331 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt @@ -110,6 +110,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 %] @@ -1502,6 +1509,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(){ @@ -1543,6 +1554,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.39.5