<?php
/** @var \Kirby\Cms\Block $block */
$image = $block->image()->toFile();
$alt = $block->alt() ?? $image->alt();
$caption = $block->caption();
$src = $image->url();
?>
<?php if ($src): ?>
<?php if ($block->link()->isNotEmpty()): ?>
<a href="<?= $block->link()->value() ?>">
<?php endif ?>  
<figure>
  <img srcset="<?= $image->srcset('full') ?>" alt="<?= $alt->esc() ?>" loading="lazy">
  <?php if ($caption->isNotEmpty()): ?>
  <figcaption>
    <?= $caption ?>
  </figcaption>
  <?php endif ?>
<?php if ($block->link()->isNotEmpty()): ?>
</a>
<?php endif ?>  
</figure>
<?php endif ?>