Bug 35558: Do not retrieve the local image if none exists

On the search results we are fetching the thumbnails of the local cover
images using catalogue/image.pl
Which means 1 GET per results on the page.

This patch suggests to have this information beforehand in order to
reduce the number of hits and network traffic?

However the page load will be slightly slower ofc.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 8cde45e072)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2023-12-13 11:10:24 +01:00 committed by Fridolin Somers
parent 813d06de27
commit 1ac5466bc2
2 changed files with 5 additions and 1 deletions

View File

@ -665,6 +665,10 @@ for (my $i=0;$i<@servers;$i++) {
if ( grep {$_ eq $line->{'biblionumber'}} @cart_list) {
$line->{'incart'} = 1;
}
if ( C4::Context->preference('LocalCoverImages') ) {
$line->{has_local_cover_image} = $line->{biblio_object}->cover_images->count;
}
}
my( $page_numbers, $hits_to_paginate, $pages, $current_page_number, $previous_page_offset, $next_page_offset, $last_page_offset ) =
Koha::SearchEngine::Search->pagination_bar(

View File

@ -473,7 +473,7 @@
[% IF ( CoverImagePlugins || AmazonCoverImages || LocalCoverImages || IntranetCoce || ( SyndeticsCovers ) || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
<td class="bookcoverimg">
<div id="cover-slides-[% SEARCH_RESULT.biblionumber | html %]" class="cover-slides" data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" data-isbn="[% To.json(SEARCH_RESULT.normalized_isbn) | $raw %]" data-processedbiblio="[% PROCESS biblio_a_href biblionumber => SEARCH_RESULT.biblionumber | $raw %]">
[% IF ( LocalCoverImages ) %]
[% IF ( LocalCoverImages && SEARCH_RESULT.has_local_cover_image ) %]
<div id="local-coverimg-[% SEARCH_RESULT.biblionumber | html %]" class="cover-image local-coverimg">
<a href="[% PROCESS biblio_a_href biblionumber => SEARCH_RESULT.biblionumber %]">
<img src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;biblionumber=[% SEARCH_RESULT.biblionumber | uri %]" alt="Local cover image" />