Skip to content

Commit 6b47b74

Browse files
authored
Hide empty cover links (#5083)
1 parent 92edda5 commit 6b47b74

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

module/VuFind/tests/integration-tests/src/VuFindTest/Mink/RecordCoverImageTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,19 @@ public function testCoverLoading(
183183
}
184184

185185
// Confirm the expected status of the image (most importantly, should it be visible or hidden?):
186+
$coverContainer = $this->findCss($page, '.record-cover-container');
187+
if ($noCoverAvailableImage) {
188+
$this->assertStringNotContainsString(
189+
'hidden',
190+
$coverContainer?->getAttribute('class') ?? ''
191+
);
192+
} else {
193+
$this->assertStringContainsString(
194+
'hidden',
195+
$coverContainer?->getAttribute('class') ?? ''
196+
);
197+
}
198+
186199
$expectedClasses = 'recordcover'
187200
. ($ajaxcovers ? ' ajax' : '')
188201
. (empty($noCoverAvailableImage) ? ' hidden' : '');

themes/bootstrap5/js/covers.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ VuFind.register('covers', function covers() {
100100
function checkImgSize(img) {
101101
if (img.getBoundingClientRect().width < 2) {
102102
img.classList.add('hidden');
103+
let recordCoverContainer = img.closest('.record-cover-container');
104+
if (recordCoverContainer !== null) {
105+
recordCoverContainer.classList.add('hidden');
106+
}
103107
}
104108
img.dataset.loaded = 'true';
105109
}

themes/bootstrap5/templates/RecordDriver/DefaultRecord/cover.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// Determine link attributes; use legacy $this->link property as a fallback for backward compatibility.
33
$linkAttributes = $this->linkAttributes ?? ($this->link ? ['href' => $this->link] : []);
44
if ($linkAttributes && !isset($linkAttributes['class'])) {
5-
$linkAttributes['class'] = 'record-cover-link';
5+
$linkAttributes['class'] = 'record-cover-container record-cover-link';
66
}
77
?>
88
<?php if ($linkAttributes): ?>
99
<a<?=$this->htmlAttributes($linkAttributes)?>>
1010
<?php else: ?>
11-
<div aria-hidden="true">
11+
<div class="record-cover-container" aria-hidden="true">
1212
<?php endif; ?>
1313
<?php /* Display thumbnail if appropriate: */ ?>
1414
<?php if ($cover): ?>

themes/bootstrap5/templates/RecordDriver/EDS/cover.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
$includeLinkInMarkup = $this->link && $cover !== false;
44
?>
55
<?php if ($includeLinkInMarkup): ?>
6-
<a href="<?=$this->escapeHtmlAttr($this->link)?>" class="record-cover-link">
6+
<a href="<?=$this->escapeHtmlAttr($this->link)?>" class="record-cover-container record-cover-link">
77
<?php else: ?>
8-
<div aria-hidden="true">
8+
<div class="record-cover-container" aria-hidden="true">
99
<?php endif; ?>
1010
<?php /* Display thumbnail if appropriate: */ ?>
1111
<?php if ($cover): ?>

0 commit comments

Comments
 (0)