0
votes

I am trying to add widget namely custom-image-widget like:

module.exports = {
  extend: 'apostrophe-widgets',
  label: 'Image',
  contextual: true,
  addFields: [{
    type: 'singleton',
    name: 'image',
    label: 'Image',
    widgetType: 'apostrophe-images',
    required: true,
    options: {
      limit: 1,
      addLabel: 'Add my background image',
      template: 'background',
      aspectRatio: [937, 299]
    }
  }, {
    type: 'string',
    name: 'caption',
    label: 'Caption',
    help: 'Optional'
  }]
}

and nunjucks html rendering in other pages is like:

  {% if myProfile or profile.image %}
    {{ apos.singleton(profile, 'image', 'custom-image', {
      addLabel: 'Add my background image',
      template: 'background'
    }) }}
  {% endif %}

Adding from the page is working fine whereas admin trying to edit the profile-pieces I am getting the below error. Please guide to resolve this issue as Page is loading and not opening the pop-up for edit profile by admin.

The widget options are not blessed. Usually this means you are editing the same widget both contextually and in a dialog box, and you are not passing the same widget options in index.js and in the template, or you are not passing the widget options in index.js at all. Either set the area to contextual: true, which keeps it out of the dialog box, or set the "widgets" option to match the last argument to "apos.area" in your template. unblessed: custom-image, {}

1

1 Answers

0
votes

Set the options object of your image singleton to be the same, both in the custom-image-widget definition and the template. Right now the template is missing aspectRatio and limit