[Koha] Display of book cover image

Michael Kuhn mik at adminkuhn.ch
Wed Mar 13 21:19:32 NZDT 2019


Hi Peter

 > For the book cover images, if we choose both Google book and Amazon,
 > for example, can we set up the system so that it’ll display the first
 > one available with the order of preference of our choice?
 >
 > Currently, it’ll display multiple images if it’s available in both of
 > them.

One way is to use Koha system preference "Coce" (see 
https://bywatersolutions.com/news/koha-tutorial-cover-images-koha-opac-coce-server 
for an example) - both Amazon and Google Books covers are available there.

In an earlier post to this list Arturo Longoria provided the following 
code - personally I haven't tested it but you may try to include it in 
system preference "OPACUserJS":

// If both local cover art and cover art from Google Books is loaded, 
only show the local cover art by hiding the Google images.
$(document).ready(function() {
   // Hide cover art when viewing a bib record.
   if (document.location.pathname === '/cgi-bin/koha/opac-detail.pl') {
     $(window).on('load', function () {
       var localImage = $('#local-thumbnail-preview').find('img')[0];
       if (localImage && localImage.naturalWidth > 1) {
         $('#gbs-thumbnail-preview').hide();
       }
     }
   }

   // Hide cover art from the search results.
   if (document.location.pathname === '/cgi-bin/koha/opac-search.pl') {
     $(window).on('load', function () {
       $('span[id*=local-thumbnail]').find('img').each(function () {
         if ($(this)[0].naturalWidth > 1) {
           $(this).parent().siblings('span').hide();
         }
       });
     });
   }
});

Hope this helps.

Best wishes: Michael
-- 
Geschäftsführer · Diplombibliothekar BBS, Informatiker eidg. Fachausweis
Admin Kuhn GmbH · Pappelstrasse 20 · 4123 Allschwil · Schweiz
T 0041 (0)61 261 55 61 · E mik at adminkuhn.ch · W www.adminkuhn.ch


More information about the Koha mailing list