init
This commit is contained in:
23
site/snippets/blocks/image.php
Normal file
23
site/snippets/blocks/image.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?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 ?>
|
||||
Reference in New Issue
Block a user