Skip to content

Commit

Permalink
Implement "thumbnail only" for merged media block
Browse files Browse the repository at this point in the history
  • Loading branch information
zerocrates committed Mar 29, 2024
1 parent df9946c commit 04f63ff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions application/src/Site/BlockLayout/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public function render(PhpRenderer $view, SitePageBlockRepresentation $block, $t
'link' => $linkType,
'showTitleOption' => $showTitleOption,
'classes' => $classes,
'mediaDisplay' => $mediaDisplay,
]);
}
}
28 changes: 24 additions & 4 deletions application/view/common/block-layout/file.phtml
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
<?php
$hyperlink = $this->plugin('hyperlink');
?>
<div class="<?php echo $this->escapeHtml(implode(' ', $classes)); ?>">
<?php foreach($attachments as $attachment): ?>
<?php $item = $attachment->item(); ?>
<div class="item resource">
<?php
$media = $attachment->media() ?: $item->primaryMedia();
if ($media):
echo $media->render([
'thumbnailType' => $thumbnailType,
'link' => $link,
]);
if ($mediaDisplay === 'thumbnail') {
switch ($link) {
case 'original':
$url = $media->originalUrl();
break;
case 'item':
$url = $item->url();
break;
case 'media':
$url = $media->url();
break;
default:
throw new \InvalidArgumentException(sprintf('Invalid link type "%s"', $linkType));
}
echo $hyperlink->raw($this->thumbnail($media, $thumbnailType), $url);
} else {
echo $media->render([
'thumbnailType' => $thumbnailType,
'link' => $link,
]);
}
endif;
?>
<?php if ($showTitleOption === 'item_title'): ?>
Expand Down

0 comments on commit 04f63ff

Please sign in to comment.