Node.js 撇号cms中图像的默认值?
我有一个自定义小部件:Node.js 撇号cms中图像的默认值?,node.js,apostrophe,apostrophe-cms,Node.js,Apostrophe,Apostrophe Cms,我有一个自定义小部件: module.exports = { extend: 'apostrophe-widgets', label: 'Banner', addFields: [ { name: 'bannerImg', type: 'attachment', label: 'Picture', def: 'http://via.placeholder.com/350x150' }
module.exports = {
extend: 'apostrophe-widgets',
label: 'Banner',
addFields: [
{
name: 'bannerImg',
type: 'attachment',
label: 'Picture',
def: 'http://via.placeholder.com/350x150'
}
]
};
和小部件视图:
<img class="logo" src="{{ apos.attachments.url(data.widget.bannerImg) }}" />
如果我加载图像,我就可以看到它。但是我没有默认值。我还可以不上传就从图库中选择文件吗?我花了半天时间找到了解决方案: 答复如下: 同样在index.js中,我更改了:
{
name: 'bannerImg',
type: 'singleton',
label: 'Banner',
widgetType: 'apostrophe-images',
options: {
limit: 1
}
},
在官方文档中,我没有找到任何关于默认值的信息。我还有一个关于单例类型小部件def值的问题
{{ apos.attachments.url(apos.images.first(data.widget.bannerImg)) }}
{
name: 'bannerImg',
type: 'singleton',
label: 'Banner',
widgetType: 'apostrophe-images',
options: {
limit: 1
}
},