@@ -, +, @@
commit 1916c644808577beb3170d642f93b456bfcc5c56
Bug 28180: Fix bug with first image does not exist
---
.../prog/en/modules/catalogue/detail.tt | 95 +++++++++----------
1 file changed, 46 insertions(+), 49 deletions(-)
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -1318,59 +1318,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"));
}
}
});
--