Skip to content

Instantly share code, notes, and snippets.

@foobartel
Created June 26, 2020 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save foobartel/71824b19ae747ffd99e3874d5a1de600 to your computer and use it in GitHub Desktop.
Save foobartel/71824b19ae747ffd99e3874d5a1de600 to your computer and use it in GitHub Desktop.
Kirby 3 Editor - Resize images in Editor snippet
<?php if( $block->isNotEmpty() ): ?>
<figure<?= attr( [ 'class' => $attrs->css()->value() ], ' ' ) ?>>
<?php if( $attrs->id()->toFile() ): ?>
<?php $imagesrc = $attrs->id()->toFile()->resize( 1200, null, 60 )->url(); ?>
<?php else: ?>
<?php $imagesrc = $src ?>
<?php endif ?>
<?php if( $attrs->link()->isNotEmpty() ): ?>
<a href="<?= $attrs->link()->toUrl() ?>">
<img src="<?= $imagesrc ?>" alt="<?= $attrs->alt() ?>" sx>
</a>
<?php else: ?>
<img src="<?= $imagesrc ?>" alt="<?= $attrs->alt() ?>">
<?php endif ?>
<?php if ( $attrs->caption()->isNotEmpty() ): ?>
<figcaption>
<?= $attrs->caption() ?>
</figcaption>
<?php endif ?>
</figure>
<?php endif ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment