I've been trying to find a good way to handle images inside of schema's, and was wondering if there's a built-in way that I've been missing. The end goal is to have a schema field where a user can select an image from the image library (as opposed to a plain attachment upload), while being able to use the crop tools and options (size, ratio, etc) that are usually used in apostrophe-image-widgets. I'm currently using a joinByOne with type apostrophe-image to make this somewhat work, but cropping is unavailable and I can't specify aspect ratios, as far as I can tell. This is the current schema definition I'm attempting to use:
{
name: '_storeImage',
label: 'Store Image',
withType: 'apostrophe-image',
type: 'joinByOne',
help: 'The image that will show on the main store page.'
}
If nothing else, is there a way to pass options into apostrophe-image to restrict aspect ratio and enable the cropping tool, or is that only available in the widget editor?
Thanks!
Use the built-in apostrophe-images-widgets
widget to select the image
{
name: 'myImage',
label: 'Image',
type: 'singleton',
widgetType: 'apostrophe-images',
options: {
aspectRatio: [ 4, 3 ],
minSize: [ 400, 300 ],
limit: [ 1 ]
}
}
Configure the options as you want them and look in the original apostrophe-images-widgets/views/widget.html
to see how to implement the image in your schema's template.