Bug 11982 - Images now display properly in the details section.
authormbeaulieu <mbeaulieu@inlibro.com>
Fri, 8 Aug 2014 13:49:53 +0000 (09:49 -0400)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 30 Mar 2015 16:45:38 +0000 (13:45 -0300)
If the a cover image exists, it will be displayed on the details page.
Nothing is displayed of there is no cover available.
    modified:   koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js
    modified:   koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Works as described, passes tests and QA script.
Checked Amazon covers and local covers display correctly
in staff on results and detail pages.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
koha-tmpl/intranet-tmpl/prog/en/js/localcovers.js
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt

index 253d7a6..ac1f885 100644 (file)
@@ -28,11 +28,10 @@ KOHA.LocalCover = {
             var img = $("<img />").attr('src',
                 '/cgi-bin/koha/catalogue/image.pl?thumbnail=1&biblionumber=' + $(mydiv).attr("class"))
                 .load(function () {
-                    if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
+                    if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth <= 1) {
                         //IE HACK
                         try {
-                            $(mydiv).append(img);
-                            $(mydiv).children('.no-image').remove();
+                            $(mydiv).remove();
                         }
                         catch(err){
                         }
index 48bc90b..a392e1a 100644 (file)
 //<![CDATA[
 // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
 function verify_images() {
-    $("#bookcoverimg img").each(function(i){
+    $("#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)) {
-                $("#bookcoverimg").remove();
-                $(".yui-gb").attr("class","yui-g");
-            } else if ((this.complete != null) && (!this.complete)) {
-                $("#bookcoverimg").remove();
-                $(".yui-gb").attr("class","yui-g");
+                w = this.width;
+                h = this.height;
+                if ((w == 1) || (h == 1)) {
+                    $("#amazon-bookcoverimg").remove();
+                    $(".yui-gb").attr("class","yui-g");
+                } else if ((this.complete != null) && (!this.complete)) {
+                    $("#amazon-bookcoverimg").remove();
+                    $(".yui-gb").attr("class","yui-g");
+                }
             }
-        }
         });
+        if( $(this).find('img').length < 1 ) $(this).remove();
+    });
        $("#editions 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;
@@ -189,7 +192,7 @@ function verify_images() {
         });
     });
 
-     [% IF ( AmazonCoverImages ) %]$(window).load(function() {
+     [% IF ( AmazonCoverImages || LocalCoverImages ) %]$(window).load(function() {
         verify_images();
      });[% END %]
 //]]>
@@ -376,17 +379,21 @@ function verify_images() {
         <span id="catalogue_detail_marc_preview" class="results_summary"><span class="label">MARC Preview:</span> <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% biblionumber %]&amp;viewas=html" title="MARC" class="previewMARC">Show</a></span>
         [% IF ( holdcount ) %]<span class="results_summary"><span class="label">Holds:</span> <span class="holdcount"><a href="/cgi-bin/koha/reserve/request.pl?biblionumber=[% biblionumber %]">[% holdcount %]</a></span></span>[% ELSE %][% END %]
 
-        [% IF ( ( AmazonEnabled && AmazonCoverImages ) || LocalCoverImages ) %]
+        [% IF ( AmazonCoverImages  || LocalCoverImages ) %]
         </div><div class="yui-u" id="bookcoverimg">
-        [% IF ( LocalCoverImages ) %]<div title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div>[% END %]
-        [% IF ( AmazonEnabled ) %][% IF ( AmazonCoverImages ) %]<div id="bookcoverimg">
-        <a href="http://www.amazon[% AmazonTld %]/gp/reader/[% normalized_isbn %]/ref=sib_dp_pt/002-7879865-0184864#reader-link">
+        [% IF ( LocalCoverImages ) %]
+            <div title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div>
+        [% END %]
+        [% IF ( AmazonCoverImages ) %]
+            <div id="amazon-bookcoverimg">
+            <a href="http://www.amazon[% AmazonTld %]/gp/reader/[% normalized_isbn %]/ref=sib_dp_pt/002-7879865-0184864#reader-link">
             [% IF ( using_https ) %]
-            <img border="0" src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="" />
+                <img border="0" src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="" />
             [% ELSE %]
-            <img border="0" src="http://images.amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="" />
+                <img border="0" src="http://images.amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="" />
             [% END %]
-        </a></div>[% END %][% END %]
+        </a></div>
+        [% END %]
         [% END %]
     [% ELSE %]
 
@@ -450,10 +457,13 @@ function verify_images() {
         </ul>
         </div>
        
-    [% IF ( ( AmazonEnabled && AmazonCoverImages ) || LocalCoverImages ) %]
+    [% IF ( AmazonCoverImages  || LocalCoverImages ) %]
         <div class="yui-u" id="bookcoverimg">
-        [% IF ( LocalCoverImages ) %]<div title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div>[% END %]
-        [% IF ( AmazonEnabled ) %][% IF ( AmazonCoverImages ) %]<div id="bookcoverimg">
+        [% IF ( LocalCoverImages ) %]
+            <div title="[% biblionumber |url %]" class="[% biblionumber %]" id="local-thumbnail-preview"></div>
+        [% END %]
+        [% IF ( AmazonCoverImages ) %]
+            <div id="amazon-bookcoverimg">
             <a href="http://www.amazon[% AmazonTld %]/gp/reader/[% normalized_isbn %]/ref=sib_dp_pt/002-7879865-0184864#reader-link">
             [% IF ( using_https ) %]
             <img border="0" src="https://images-na.ssl-images-amazon.com/images/P/[% normalized_isbn %].01.MZZZZZZZ.jpg" alt="" />
@@ -462,7 +472,7 @@ function verify_images() {
             [% END %]
             </a>
         </div>
-        [% END %][% END %]
+        [% END %]
         </div>
     [% END %]
         
index 933453c..785da66 100644 (file)
@@ -16,7 +16,7 @@ var q_array = new Array();  // will hold search terms, if present
 // http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
 function verify_images() {
     $("img").each(function(i){
-        if ((this.src.indexOf('images.amazon.com') >= 0) || (this.src.indexOf('g-images.amazon.com') >=0)) {
+        if ((this.src.indexOf('images-amazon.com') >= 0) || (this.src.indexOf('images.amazon.com') >=0)) {
             w = this.width;
             h = this.height;
             if ((w == 1) || (h == 1)) {