Apostrophe-CMS架构映像

时间:2019-01-13 10:24:20

标签: apostrophe-cms

我一直在努力寻找一种在架构内部处理图像的好方法,并且想知道是否存在我所缺少的内置方法。最终目标是拥有一个架构字段,用户可以在其中从图像库中选择一个图像(与普通附件上传相对),同时能够使用通常使用的裁剪工具和选项(大小,比率等)用于撇号图像小部件。我目前正在使用带有撇号图像类型的joinByOne来使其有些工作,但是据我所知,裁剪不可用,我无法指定纵横比。这是我正在尝试使用的当前架构定义:

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

如果没有其他选择,是否有办法将选项传递到撇号图像中以限制长宽比并启用裁剪工具,或者仅在窗口小部件编辑器中可用?

谢谢!

1 个答案:

答案 0 :(得分:1)

使用内置的apostrophe-images-widgets小部件选择图像

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

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