[Koha] Display of book cover image

Arturo Longoria Arturo.Longoria at sll.texas.gov
Thu Mar 14 02:32:49 NZDT 2019


The jQuery snippet I'd written will need some minor editing to target which cover art you want to hide. And keep in mind that the image has to load before you can detect it with JavaScript, so you can't prevent an image from displaying, but you can hide it.

This code was not in the jQuery Library on the Koha wiki, so I've added it here:
https://wiki.koha-community.org/wiki/JQuery_Library#Show_local_cover_art_instead_of_Google_Books_cover_art_if_both_are_present

Arturo Longoria
Reference Librarian/Web Manager
Texas State Law Library
www.sll.texas.gov

-----Original Message-----
From: Koha <koha-bounces at lists.katipo.co.nz> On Behalf Of Michael Kuhn
Sent: Wednesday, March 13, 2019 03:20
To: koha at lists.katipo.co.nz
Subject: Re: [Koha] Display of book cover image

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 _______________________________________________
Koha mailing list  http://koha-community.org Koha at lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha


More information about the Koha mailing list