steirico / kirby-plugin-image-crop-field

Kirby image crop field based on vue-cropperjs and gumlet/php-image-resize
MIT License
15 stars 3 forks source link

New default image block #25

Open fritzlaszlo opened 3 years ago

fritzlaszlo commented 3 years ago

Hi there,

thanks for this fantastic plugin!

I ran into problems when using it with the new default image block. I tried to adapt the piece of code from your instructions to: <?= $block->image()->croppedImage() ?> But this throws an Error: Block error: "Array to string conversion" in block type: "image" Any quick ideas or hints?

steirico commented 3 years ago

Hi,

The plugin comes from a time before Kirby introduced blocks. As such, I've not used the plugin in blocks yet. But that's definitively something to consider.

Nevertheless, the plugin actually works with some limitations:

  1. Block preview in the panel is not available
  2. The plugin's field has to be used in file blueprints (c.f. README.md)

In order to use the cropped image in your templates/snippets, one have to get the image's file and then call the plugin's file method croppedImage(). So your code becomes this:

<?= $block->image()->toFile()->croppedImage() ?>

Using the starterkit and changing line 27 of /site/snippets/blocks/image.php accordingly worked for me.