- $("#bookcoverimg").each(function(i){
- $(this).find('img').each(function(i){
- if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0) || (this.src.indexOf('images-na.ssl-images-amazon.com'))) {
- w = this.width;
- h = this.height;
- if ((w == 1) || (h == 1)) {
- $("#amazon-bookcoverimg").remove();
- } else if ((this.complete != null) && (!this.complete)) {
- $("#amazon-bookcoverimg").remove();
+ // Loop over each container in the template which contains covers
+ $(".cover-slider").each(function(){
+ var lightbox_descriptions = [];
+ $(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 (<a href='%s'>see the original image</a>)").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") == "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("id") == "adlibris-coverimg" ){
+ lightbox_descriptions.push(_("Image from Adlibris (<a href='%s'>see the original image</a>)").format($(img).data('link')));
+ } else if ( div.attr("class") == "cover-image local-coverimg" ) {
+ lightbox_descriptions.push(_("Local cover image (<a href='%s'>edit</a>)").format($(img).data('link')));
+ } else {
+ lightbox_descriptions.push(_("Cover image source unknown"));
+ }