Skip to content

Commit

Permalink
Merge pull request #3 from dartmouth-dltg/image-select
Browse files Browse the repository at this point in the history
get images even when the order of media is random
  • Loading branch information
jdshaw authored Sep 29, 2022
2 parents ad008fe + 2bf132c commit d356f8b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions view/random-items-block/common/block-layouts/random-items.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@
<<?php echo $header_level; ?>><?php echo $initialItem->displayTitle(); ?></<?php echo $header_level; ?>>
<?php endif; ?>
<div class="random-item-image">
<?php $imageMedia = $initialItem->primaryMedia(); ?>
<?php
$imageMedia = null;
$description = '';
foreach ($initialItem->media() as $media) {
if (strpos($media->mediaType(), 'image') !== false) {
$imageMedia = $media;
}
if ($media->value('dcterms:type') == 'storybooth' && $description == '') {
$description = $media->render();
}
}
$description = $description == '' ? '<p>' . $initialItem->displayDescription() . '</p>' : $description;
?>
<?php if ($imageMedia): ?>
<?php if ($linkItems): ?>
<?php echo $initialItem->linkRaw($this->thumbnail($imageMedia, 'large')); ?>
Expand All @@ -36,16 +48,6 @@
<?php endif; ?>
</div>
<div class="random-item-description">
<?php $description = ''; ?>
<?php foreach ($initialItem->media() as $media): ?>
<?php $thismediatype = $media->value('dcterms:type'); ?>
<?php if ($thismediatype == 'storybooth'): ?>
<?php $description = $media->render(); ?>
<?php break; ?>
<?php else: ?>
<?php $description = '<p>' . $initialItem->displayDescription() . '</p>'; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php echo $description; ?>
<?php if ($block->dataValue('userRandom') == 1): ?>
<?php if (count($initialItems) == 1 && $block->dataValue('userRandomPlacement') == 1) : ?>
Expand Down

0 comments on commit d356f8b

Please sign in to comment.