From d534d9186ce5af4b7054fe021c3a1d4afd2c3d55 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 25 Nov 2022 07:04:43 +0100 Subject: [PATCH] Bug 32307: (follow-up) Fix gallery when Coce is enabled Yet another fix, this is porting the following change to the intranet: commit 1916c644808577beb3170d642f93b456bfcc5c56 Bug 28180: Fix bug with first image does not exist To recreate the problem: Enable Coce Go to biblionmber=5 detail => No image (but one is displayed on the search result) Add a local cover image => Only the local cover image is displayed Apply this patch => Both images are displayed Remove the local cover image => Image from coce is displayed Signed-off-by: David Nind Signed-off-by: Marcel de Rooy Signed-off-by: Tomas Cohen Arazi --- .../prog/en/modules/catalogue/detail.tt | 95 +++++++++---------- 1 file changed, 46 insertions(+), 49 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 5330deb5cb..2e20d2e520 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1320,59 +1320,56 @@ Note that permanent location is a code, and location may be an authval. // Loop over each container in the template which contains covers $(".cover-slider").each(function(){ var lightbox_descriptions = []; + var first_shown = 0; $(this).find(".cover-image").each( function( index ){ - var div = $(this); - // Find the image in the container - var img = div.find("img")[0]; - if( $(img).length > 0 ){ - var description = ""; - if( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ){ - // No image loaded in the container. Remove the slide - div.remove(); - } else { - // All slides start hidden. If this is the first one, show it. - if( index == 0 ){ - div.show(); - } - // Check if Amazon image is present - if ( div.attr("id") == "amazon-bookcoverimg" ) { - w = img.width; - h = img.height; - if ((w == 1) || (h == 1)) { - // Amazon returned single-pixel placeholder - // Remove the container - div.remove(); - } else { - lightbox_descriptions.push(_("Amazon cover image (see the original image)").format($(img).data('link'))); - } - } else if( div.attr("id") == "custom-coverimg" ){ - if ( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ) { - // No image was loaded via the CustomCoverImages system preference - // Remove the container - div.remove(); - } else { - lightbox_descriptions.push("Custom cover image"); - } - } else if ( div.attr("id") == "syndetics-bookcoverimg" ){ - lightbox_descriptions.push(_("Syndetics cover image (see the original image)").format($(img).data('link'))); + var div = $(this); + // Find the image in the container + var img = div.find("img")[0]; + if( $(img).length > 0 ){ + var description = ""; + // All slides start hidden. If this is the first one, show it. + if( first_shown == 0 ){ + div.show(); + first_shown = 1; + } + // Check if Amazon image is present + if ( div.attr("id") == "amazon-bookcoverimg" ) { + w = img.width; + h = img.height; + if ((w == 1) || (h == 1)) { + // Amazon returned single-pixel placeholder + // Remove the container + div.remove(); + } else { + lightbox_descriptions.push(_("Amazon cover image (see the original image)").format($(img).data('link'))); } - else if( div.hasClass("coce-coverimg" ) ){ - // Identify which service's image is being loaded by Coce - var coce_description; - if( $(img).attr("src").indexOf('amazon.com') >= 0 ){ - coce_description = ("Coce image from Amazon.com"); - } else if( $(img).attr("src").indexOf('google.com') >= 0 ){ - coce_description = _("Coce image from Google Books"); - } else if( $(img).attr("src").indexOf('openlibrary.org') >= 0 ){ - coce_description = _("Coce image from Open Library"); - } - div.find(".hint").html(coce_description); - lightbox_descriptions.push(coce_description); - } else if ( div.attr("class") == "cover-image local-coverimg" ) { - lightbox_descriptions.push(_("Local cover image (edit)").format($(img).data('link'))); + } else if( div.attr("id") == "custom-coverimg" ){ + if ( (img.complete != null) && (!img.complete) || img.naturalHeight == 0 ) { + // No image was loaded via the CustomCoverImages system preference + // Remove the container + div.remove(); } else { - lightbox_descriptions.push(_("Cover image source unknown")); + lightbox_descriptions.push("Custom cover image"); } + } else if ( div.attr("id") == "syndetics-bookcoverimg" ){ + lightbox_descriptions.push(_("Syndetics cover image (see the original image)").format($(img).data('link'))); + } + else if( div.hasClass("coce-coverimg" ) ){ + // Identify which service's image is being loaded by Coce + var coce_description; + if( $(img).attr("src").indexOf('amazon.com') >= 0 ){ + coce_description = ("Coce image from Amazon.com"); + } else if( $(img).attr("src").indexOf('google.com') >= 0 ){ + coce_description = _("Coce image from Google Books"); + } else if( $(img).attr("src").indexOf('openlibrary.org') >= 0 ){ + coce_description = _("Coce image from Open Library"); + } + div.find(".hint").html(coce_description); + lightbox_descriptions.push(coce_description); + } else if ( div.attr("class") == "cover-image local-coverimg" ) { + lightbox_descriptions.push(_("Local cover image (edit)").format($(img).data('link'))); + } else { + lightbox_descriptions.push(_("Cover image source unknown")); } } }); -- 2.39.5