Custom block image preview - cant read property "url"

Hey,

i just want to create a custom image block:

panel.plugin("name/help-resource-description-image", {
  blocks: {
    help__resource__image: `
    <img style="margin-left: 67px; width: 200px; background-color: grey;" :src="content.image_page_data[0].url"   >
    `,
  },
});

this works if there is already an url. When i add a new “imageblock” this error appears: Cannot “read property ‘url’ of undefined”

i mean its obvious - there is no url.
i tried to add vue contitions, but i am doing sth wrong:

  <div v-if="content.image_page_data[0].url !== undefined" >
    <img   style="margin-left: 67px; width: 200px; background-color: grey;" :src="content.image_page_data[0].url"   >
    </div>

See my soon to be published new recipe, from line 345:

2 Likes

exactly what i was looking for! thank you