decor-6-site/site/snippets/blocks/imagefloat.php
2026-04-11 18:57:03 +02:00

23 lines
No EOL
557 B
PHP

<?php
/** @var \Kirby\Cms\Block $block */
$alt = $block->alt();
$caption = $block->caption();
$src = $block->image()->toFile()->url();
$GLOBALS['figCount'] = ($GLOBALS['figCount'] ?? 0) + 1;
$figId = 'fig-' . Str::slug($block->parent()?->author() ?? '') . '-' . $GLOBALS['figCount'];
?>
<?php if ($src): ?>
<figure id="<?= $figId ?>" class="float-image">
<img src="<?= $src ?>" alt="<?= $alt->esc() ?>">
<?php if ($caption->isNotEmpty()): ?>
<figcaption>
<?= $caption->kt() ?>
</figcaption>
<?php endif ?>
</figure>
<?php endif ?>