I store x and y values in a custom field, which are passed as an array.
Kirby::plugin('fb/image-crop-field', [
'fields' => [
'imagecropfield' => [
'props' => [
'label' => function (string $label = null) {
return $label ?? 'Image Crop Field';
},
'value' => function ($value = null) {
return $value;
},
'image' => function ($image = null) {
return $image;
}
],
'save' => function ($value = null) {
if ($value && is_array($value)) {
$json = [
'x' => (float)$value['x'],
'y' => (float)$value['y']
];
return $json;
}
return null;
}
]
]
]);
Kirby saves the data in this form:
----
Crop:
x: 0.141745
y: 0.00678
----
Under value I get the content back as plain text. How do I stay in the object?