geoproject-app/public/site/snippets/blocks/map.php

41 lines
1.1 KiB
PHP
Raw Normal View History

2025-12-02 21:45:22 +01:00
<?php
/** @var \Kirby\Cms\Block $block */
$alt = $block->alt();
$caption = $block->caption();
$link = $block->link();
$width = $block->width()->or('100%');
$position = $block->position()->or('auto');
$src = null;
if ($block->location() == 'web') {
$src = $block->src()->esc();
} elseif ($image = $block->image()->toFile()) {
$alt = $alt->or($image->alt());
$src = $image->url();
}
?>
<?php if ($src): ?>
<figure style="width:<?= $width ?>; min-width:225px; margin:<?= $position ?>; margin-bottom:1.5em;">
<?php if ($link->isNotEmpty()): ?>
<a href="<?= Str::esc($link->toUrl()) ?>">
<img src="<?= $src ?>" alt="<?= $alt->esc() ?>" loading="lazy">
</a>
<?php else: ?>
<a href="<?= $src ?>" class="glightbox" <?php if($caption->isNotEmpty()):?>
data-glightbox="title: <?= $caption ?>"
<?php endif?>>
<img src="<?= $src ?>" alt="<?= $alt->esc() ?>" loading="lazy">
</a>
<?php endif ?>
<?php if ($caption->isNotEmpty()): ?>
<figcaption>
<?= $caption ?>
</figcaption>
<?php endif ?>
</figure>
<?php endif ?>