How to specify medias crops for blocks.

Hi. I've got a block that accepts medias and want to set a crop for it. I've tried doing it within the parent model that the block would be added to but the changes never get saved despite the editor detecting the crop i've configured i.e. I add the block in the block editor, I select an image and set a crop but it never gets linked to the block instance and doesn't render. Am I missing something? Block:
<x-twill::medias
name="articleHeroImage"
label="Article Image"
/>
<x-twill::medias
name="articleHeroImage"
label="Article Image"
/>
Parent Model $mediasParams:
'articleHeroImage' => [
'desktop' => [
[
'name' => 'desktop',
'ratio' => 9/6,
],
],
],
'articleHeroImage' => [
'desktop' => [
[
'name' => 'desktop',
'ratio' => 9/6,
],
],
],
2 Replies
ifox
ifox3mo ago
Hi @Senior blocks crop settings are not set on the model because a block can be used by multiple models. They can be set in twill.php config under block_editor.crops, or within block class files.
Senior
SeniorOP3mo ago
I knew I must have missed something. Works perfectly now, thanks a lot!
Want results from more Discord servers?
Add your server