Skip to content
Snippets Groups Projects
Commit d2427e27 authored by Robert Lange's avatar Robert Lange
Browse files

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
parent 1d5c884d
No related merge requests found
/* global Finc */ /* global Finc */
// show picture in large size after click within a modal // 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) { if (anchor === null || anchor === undefined || url === null || url === undefined) {
return; return;
} }
...@@ -8,7 +8,7 @@ function registerCoverForModal(anchor, url) { ...@@ -8,7 +8,7 @@ function registerCoverForModal(anchor, url) {
anchor.click(function(event) { anchor.click(function(event) {
event.preventDefault(); event.preventDefault();
VuFind.modal('show'); VuFind.modal('show');
var largeSizeUrl = url + '&size=large'; var largeSizeUrl = url + (size ? '&size=' + size : '');
$.get(largeSizeUrl).done(function() { $.get(largeSizeUrl).done(function() {
$('#modal').find('.modal-body').html('<img src="' + largeSizeUrl + '">'); $('#modal').find('.modal-body').html('<img src="' + largeSizeUrl + '">');
}).fail(function() { }).fail(function() {
...@@ -34,7 +34,7 @@ function loadCoverByElement(data, element) { ...@@ -34,7 +34,7 @@ function loadCoverByElement(data, element) {
anchor.show(); anchor.show();
anchor.attr('href', response.data.url); anchor.attr('href', response.data.url);
// finc specific // finc specific
registerCoverForModal(anchor, response.data.url); registerCoverForModal(anchor, response.data.url, 'large');
if (data.ariaLabel) { if (data.ariaLabel) {
anchor.attr('aria-label', data.ariaLabel); anchor.attr('aria-label', data.ariaLabel);
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<?= $this->render('RecordDriver/DefaultRecord/offcanvas-toggler'); ?> <?= $this->render('RecordDriver/DefaultRecord/offcanvas-toggler'); ?>
<?php <?php
$QRCode = $this->record($this->driver)->getQRCode("core"); $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']; $cover = $coverDetails['html'];
$preview = ($this->previewOverride ?? false) $preview = ($this->previewOverride ?? false)
? $this->previewOverride : $this->record($this->driver)->getPreviews(); ? $this->previewOverride : $this->record($this->driver)->getPreviews();
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
<?php /* finc: this one is very special, see revisions for context */ <?php /* finc: this one is very special, see revisions for context */
/*If you want to load covers in lightbox use '.recordcover'; /*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 */ ?> 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 $id = $driver->getUniqueID() ?>
<?php $title = $this->transEsc($driver->getTitle()); ?> <?php $title = $this->transEsc($driver->getTitle()); ?>
<?php $alt = $this->transEscAttr('Cover Image') . ' ' . $this->transEscAttr("of") . ' ' . $title;?>
<?php <?php
if ($id) { if ($id) {
...@@ -16,39 +16,44 @@ ...@@ -16,39 +16,44 @@
?> ?>
<?php if ($cover): ?> <?php if ($cover): ?>
<?php /* load cover directly... */ ?> <?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): ?> <?php if ($this->link): ?>
</a> <a
<script> id="<?=$coverId?>"
registerCoverForModal($('#<?=$coverId?>'), '<?=$cover?>'); href="<?=$this->escapeHtmlAttr($this->link)?>"
</script> 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 endif; ?>
<?php elseif ($cover === false): ?> <?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" /> <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 else: ?>
<?php /* load cover by ajax */ ?> <?php /* load cover by ajax */ ?>
<div id="<?=$coverId?>" class="ajaxcover"> <div id="<?=$coverId?>" class="ajaxcover">
<div class="spinner"><i class="fa fa-spinner fa-spin"></i></div> <div class="spinner"><i class="fa fa-spinner fa-spin"></i></div>
<div class="cover-container"> <div class="cover-container">
<?=$this->setIconText = false;?> <?=$this->setIconText = false;?>
<?=$this->render('record/coverReplacement')?>
<a class="coverlink hidden" href="javascript:" aria-hidden="true" tabindex="-1"> <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> <script>
loadCoverByElement( loadCoverByElement(
{ {
recordId:'<?=$this->escapeHtmlAttr($driver->getUniqueID())?>', recordId:'<?=$this->escapeHtmlAttr($driver->getUniqueID())?>',
alt:'<?=$this->transEscAttr('Cover Image')?> <?=$this->transEscAttr("of")?> <?=$title?>', alt:'<?=$alt?>',
ariaLabel:'<?=$this->transEscAttr("Link-to")?> <?=$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)?>', size:'<?=$this->escapeHtmlAttr($size)?>',
source:'<?=$this->escapeHtmlAttr($driver->getSourceIdentifier())?>' source:'<?=$this->escapeHtmlAttr($driver->getSourceIdentifier())?>'
}, },
$('#<?=$coverId?>') $('#<?=$coverId?>')
); );
</script> </script>
</a> </a>
</div> </div>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?=$this->record($this->driver)->getRecordIconText()?> <?=$this->record($this->driver)->getRecordIconText()?>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment