decor-6-site/site/snippets/blocks/spreadimage.php

28 lines
645 B
PHP
Raw Normal View History

2026-01-05 19:33:15 +01:00
<?php
/** @var \Kirby\Cms\Block $block */
$alt = $block->alt();
$caption = $block->caption();
$src = null;
$fullWidth = $block->fullwidth()->toBool();
if ($block->location() == 'web') {
$src = $block->src()->esc();
} elseif ($image = $block->image()->toFile()) {
$alt = $alt->or($image->alt());
$src = $image->url();
}
?>
<?php if ($src): ?>
<div class="spread-image">
<figure class="<?= $fullWidth ? 'full-width' : '' ?>">
<img src="<?= $src ?>" alt="<?= $alt->esc() ?>">
<?php if ($caption->isNotEmpty()): ?>
<figcaption><?= $caption ?></figcaption>
<?php endif ?>
</figure>
</div>
<?php endif ?>