From d2427e2731f171c3651a0beff252fa9be05c1c0b Mon Sep 17 00:00:00 2001 From: Robert Lange <robert.lange@uni-leipzig.de> Date: Mon, 3 Apr 2023 15:38:46 +0200 Subject: [PATCH] refs #22058 [finc] handle thumbs from solr * since vufind #1566 covers from solr fields are rendered directly and not by ajax, even if it's configured * therefore an implementation for BARF attributes has become more necessary * when loading covers directly, prefer link over cover link --- themes/finc/js/covers.js | 6 +-- .../RecordDriver/DefaultRecord/core.phtml | 2 +- .../RecordDriver/DefaultRecord/cover.phtml | 49 ++++++++++--------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/themes/finc/js/covers.js b/themes/finc/js/covers.js index e1235742b58..b9ae3412c32 100644 --- a/themes/finc/js/covers.js +++ b/themes/finc/js/covers.js @@ -1,6 +1,6 @@ /* global Finc */ // show picture in large size after click within a modal -function registerCoverForModal(anchor, url) { +function registerCoverForModal(anchor, url, size) { if (anchor === null || anchor === undefined || url === null || url === undefined) { return; } @@ -8,7 +8,7 @@ function registerCoverForModal(anchor, url) { anchor.click(function(event) { event.preventDefault(); VuFind.modal('show'); - var largeSizeUrl = url + '&size=large'; + var largeSizeUrl = url + (size ? '&size=' + size : ''); $.get(largeSizeUrl).done(function() { $('#modal').find('.modal-body').html('<img src="' + largeSizeUrl + '">'); }).fail(function() { @@ -34,7 +34,7 @@ function loadCoverByElement(data, element) { anchor.show(); anchor.attr('href', response.data.url); // finc specific - registerCoverForModal(anchor, response.data.url); + registerCoverForModal(anchor, response.data.url, 'large'); if (data.ariaLabel) { anchor.attr('aria-label', data.ariaLabel); } diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/core.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/core.phtml index 3535d07483a..3eeaf9847cb 100644 --- a/themes/finc/templates/RecordDriver/DefaultRecord/core.phtml +++ b/themes/finc/templates/RecordDriver/DefaultRecord/core.phtml @@ -5,7 +5,7 @@ <?= $this->render('RecordDriver/DefaultRecord/offcanvas-toggler'); ?> <?php $QRCode = $this->record($this->driver)->getQRCode("core"); - $coverDetails = $this->record($this->driver)->getCoverDetails('core', 'medium', $this->record($this->driver)->getThumbnail('large')); + $coverDetails = $this->record($this->driver)->getCoverDetails('core', 'medium', $this->record($this->driver)->getThumbnail('medium')); $cover = $coverDetails['html']; $preview = ($this->previewOverride ?? false) ? $this->previewOverride : $this->record($this->driver)->getPreviews(); diff --git a/themes/finc/templates/RecordDriver/DefaultRecord/cover.phtml b/themes/finc/templates/RecordDriver/DefaultRecord/cover.phtml index 5047db5ac87..09390599e73 100644 --- a/themes/finc/templates/RecordDriver/DefaultRecord/cover.phtml +++ b/themes/finc/templates/RecordDriver/DefaultRecord/cover.phtml @@ -3,9 +3,9 @@ <?php /* finc: this one is very special, see revisions for context */ /*If you want to load covers in lightbox use '.recordcover'; the class '.nocover' prevents nocover images from loading in lightbox or can be used to hide the images */ ?> -<?php $alt = $alt ?? $this->transEsc('Cover Image')?> <?php $id = $driver->getUniqueID() ?> <?php $title = $this->transEsc($driver->getTitle()); ?> +<?php $alt = $this->transEscAttr('Cover Image') . ' ' . $this->transEscAttr("of") . ' ' . $title;?> <?php if ($id) { @@ -16,39 +16,44 @@ ?> <?php if ($cover): ?> <?php /* load cover directly... */ ?> - <?php if ($this->link): ?><a id="<?=$coverId?>" href="<?=$this->escapeHtmlAttr($this->link)?>" tabindex="-1" aria-hidden="true"><?php endif; ?> - <img alt="<?=$alt?>" <?php if ($linkPreview): ?>data-linkpreview="true" <?php endif; ?>class="recordcover" src="<?=$this->escapeHtmlAttr($cover); ?>" /> <?php if ($this->link): ?> - </a> - <script> - registerCoverForModal($('#<?=$coverId?>'), '<?=$cover?>'); - </script> + <a + id="<?=$coverId?>" + href="<?=$this->escapeHtmlAttr($this->link)?>" + ariaLabel="<?=$this->transEscAttr('Link-to')?> <?=$this->transEscAttr('Cover Image')?> <?=$this->transEscAttr('of')?> <?=$title?>" + > + <?php endif; ?> + <img alt="<?=$alt?>" <?php if ($linkPreview): ?>data-linkpreview="true" <?php endif; ?>class="recordcover" src="<?=$this->escapeHtmlAttr(($this->link ?? $cover)); ?>" /> + <?php if ($this->link): ?> + </a> + <script> + registerCoverForModal($('#<?=$coverId?>'), '<?=$cover?>'); + </script> <?php endif; ?> <?php elseif ($cover === false): ?> <img src="<?=$this->url('cover-unavailable')?>" <?php if ($linkPreview): ?>data-linkpreview="true" <?php endif; ?>class="nocover" alt="<?=$this->transEscAttr('No Cover Image')?>" aria-hidden="true" tabindex="-1" /> <?php else: ?> <?php /* load cover by ajax */ ?> <div id="<?=$coverId?>" class="ajaxcover"> - <div class="spinner"><i class="fa fa-spinner fa-spin"></i></div> - <div class="cover-container"> + <div class="spinner"><i class="fa fa-spinner fa-spin"></i></div> + <div class="cover-container"> <?=$this->setIconText = false;?> - <?=$this->render('record/coverReplacement')?> <a class="coverlink hidden" href="javascript:" aria-hidden="true" tabindex="-1"> - <img <?php if ($linkPreview): ?>data-linkpreview="true" <?php endif; ?> class="recordcover ajax" src="<?=$this->imageLink('noCover2.gif')?>" alt="<?=$this->escapeHtmlAttr($alt); ?>" /> + <img <?php if ($linkPreview): ?>data-linkpreview="true" <?php endif; ?> class="recordcover ajax" src="<?=$this->url('cover-unavailable')?>" alt="<?=$this->escapeHtmlAttr($alt); ?>" /> <script> - loadCoverByElement( - { - recordId:'<?=$this->escapeHtmlAttr($driver->getUniqueID())?>', - alt:'<?=$this->transEscAttr('Cover Image')?> <?=$this->transEscAttr("of")?> <?=$title?>', - ariaLabel:'<?=$this->transEscAttr("Link-to")?> <?=$this->transEscAttr('Cover Image')?> <?=$this->transEscAttr("of")?> <?=$title?>', - size:'<?=$this->escapeHtmlAttr($size)?>', - source:'<?=$this->escapeHtmlAttr($driver->getSourceIdentifier())?>' - }, - $('#<?=$coverId?>') - ); + loadCoverByElement( + { + recordId:'<?=$this->escapeHtmlAttr($driver->getUniqueID())?>', + alt:'<?=$alt?>', + ariaLabel:'<?=$this->transEscAttr("Link-to")?> <?=$this->transEscAttr('Cover Image')?> <?=$this->transEscAttr("of")?> <?=$title?>', + size:'<?=$this->escapeHtmlAttr($size)?>', + source:'<?=$this->escapeHtmlAttr($driver->getSourceIdentifier())?>' + }, + $('#<?=$coverId?>') + ); </script> </a> - </div> + </div> </div> <?php endif; ?> <?=$this->record($this->driver)->getRecordIconText()?> -- GitLab