From 9ccf0dcdc33738b92bbffbb10d2d08f4df1310f1 Mon Sep 17 00:00:00 2001
From: Alex Buckley <alexbuckley@catalyst.net.nz>
Date: Wed, 24 Aug 2022 16:12:06 +0000
Subject: [PATCH] Bug 31446: Optionally hide the Opac lightbox image
 description

Test plan:
1. Apply patches, update database and restart services

2. Observe the new system preference OpacLightboxImageDescriptions is
set to 'Show'

3. Enable OpacAmazonCoverImages, GoogleJackets, Coce (CoceHost =
'https://coce.mykoha.co.nz', CoceProviders = select all, OpacCoce =
'Enable)

4. In the OPAC visit the item detail page of a record displaying multiple cover images in a gallery - (If such an item does not exist in your catalogue add the ISBN (020$a) of '9780080969572' to a biblio)

5. Observe descriptions are displayed under each image in the gallery
indicating where the items are from - e.g. 'Coce image from Amazon.com'

6. Change the OpacLightboxImageDescriptions syspref to "Don't show"

7. Confirm all the image descriptions are hidden in the OPAC item detail
page. However, the dots to skip between the different cover images
should still be visible.

8. Disable OpacAmazonCoverImages and Googlejackets sysprefs. Confirm
with only Coce images enabled the image descriptions are still hidden.

Sponsored-by: Toi Ohomai Institute of Technology, New Zealand
---
 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt | 5 +++++
 opac/opac-detail.pl                                     | 4 ++++
 2 files changed, 9 insertions(+)

diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
index e69c3fac730..ad716ffffd6 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-detail.tt
@@ -1558,6 +1558,11 @@
                     } else {
                         div.remove();
                     }
+
+                    // Optionally hide the Lightbox image descriptions
+                    [% IF ( !OpacLightboxImageDescriptions ) %]
+                        div.find(".hint").hide();
+                    [% END %]
                 });
 
                 // Lightbox for cover images
diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl
index 1c5e7949abd..03d7340a5af 100755
--- a/opac/opac-detail.pl
+++ b/opac/opac-detail.pl
@@ -1163,6 +1163,10 @@ if (C4::Context->preference("OPACURLOpenInNewWindow")) {
     $template->param(covernewwindow => 'false');
 }
 
+if (C4::Context->preference("OpacLightboxImageDescriptions")) {
+    $template->param( OpacLightboxImageDescriptions => 1 );
+}
+
 $template->param(borrowernumber => $borrowernumber);
 
 if ( C4::Context->preference('OpacStarRatings') !~ /disable/ ) {
-- 
2.20.1