撇号-CMS 模式图像

Apostrophe-CMS Schema Image

我一直在努力寻找一种处理模式内部图像的好方法,并且想知道是否有一种我一直缺少的内置方法。最终目标是拥有一个架构字段,用户可以在其中 select 图片库中的图片(而不是普通的附件上传),同时能够使用裁剪工具和选项(大小、比例等) ) 通常用在 apostrophe-image-widgets 中。我目前正在使用 apostrophe-image 类型的 joinByOne 来使它有点工作,但据我所知,裁剪不可用并且我无法指定纵横比。这是我尝试使用的当前模式定义:

{
    name: '_storeImage',
    label: 'Store Image',
    withType: 'apostrophe-image',
    type: 'joinByOne',
    help: 'The image that will show on the main store page.'
}

如果不出意外,有没有办法将选项传递给 apostrophe-image 以限制宽高比并启用裁剪工具,或者只能在小部件编辑器中使用?

谢谢!

使用内置的 apostrophe-images-widgets 小部件 select 图片

{
  name: 'myImage',
  label: 'Image',
  type: 'singleton',
  widgetType: 'apostrophe-images',
  options: {
    aspectRatio: [ 4, 3 ],
    minSize: [ 400, 300 ],
    limit: [ 1 ]
  }
}

根据需要配置选项并查看原始 apostrophe-images-widgets/views/widget.html 以了解如何在您的架构模板中实现图像。