Hey everyone!
I’ve started using the new editor and would like to extend the image class to have a second type of image to which I can add another class. It already shows up in the editor itself but the block doesn’t appear on the actual website. Could you please help me figure out what’s wrong?
index.php:
Kirby::plugin('smiddyburbon/onecolumn-image-block', [
'snippets' => [
'editor/onecolumn-image' => __DIR__ . '/snippets/onecolumn-image.php'
]
]);
onecolumn-image.php (copied from snippets/image.php):
<?php if ($block->isNotEmpty()): ?>
<figure<?= attr(['class' => $attrs->css()->value()], ' ') ?>>
<?php if ($attrs->link()->isNotEmpty()): ?>
<a href="<?= $attrs->link()->toUrl() ?>">
<img src="<?= $src ?>" alt="<?= $attrs->alt() ?>">
</a>
<?php else: ?>
<img src="<?= $src ?>" alt="<?= $attrs->alt() ?>">
<?php endif ?>
<?php if ($attrs->caption()->isNotEmpty()): ?>
<figcaption>
<?= $attrs->caption() ?>
</figcaption>
<?php endif ?>
</figure>
<?php endif ?>
index.js:
editor.block("onecolumn-image", {
extends: "image",
// will appear as title in the blocks dropdown
label: "OneColumn Image",
// icon for the blocks dropdown
icon: "image",
});
Best,
Dennis