From 1ac5466bc234ac1f668dff655fe7c68bd797f904 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 13 Dec 2023 11:10:24 +0100 Subject: [PATCH] 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 Signed-off-by: Nick Clemens Signed-off-by: Katrin Fischer (cherry picked from commit 8cde45e0723a4b34bdf26c7ef4cfd2d8e767c837) Signed-off-by: Fridolin Somers --- catalogue/search.pl | 4 ++++ koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index 6228389717..045a5ed182 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -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( diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt index 8e5e2bb141..947a4935d4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt @@ -473,7 +473,7 @@ [% IF ( CoverImagePlugins || AmazonCoverImages || LocalCoverImages || IntranetCoce || ( SyndeticsCovers ) || (Koha.Preference('CustomCoverImages') && Koha.Preference('CustomCoverImagesURL')) ) %]
- [% IF ( LocalCoverImages ) %] + [% IF ( LocalCoverImages && SEARCH_RESULT.has_local_cover_image ) %]