Create image widget with Data URL

  • 23 May 2021
  • 1 reply
  • 59 views

Userlevel 2
Badge +2

Hi,

 

Is it possible to create image widget with data URL such as data:image/jpeg;base64,/9j/4…

When I attempt to do so it throws error Error: 'url' field is required for ImageWidget

 

Regards,

Ram


1 reply

Userlevel 7
Badge +11

@Ramkumar

I’m not entirely positive, but I’m pretty sure the answer is “no”. 

Image widget are read-only with the Miro REST API. 
you can create them with the SDK- But.. I think the following logic is key to consider. An inline dataURL works for a browser reading an html page - but outside of that runtime the URL has no root context. I believe the way the Miro Sdk works is that when it makes an image widget it instantiates the widget with its associated web URL source, the Miro back end fetches that image from that given url, loads it into your board’s file system — and then and each time you re-open that board, it loads that image, from its own board canvas data-URL, at board-load-time.

 

Not sure if it helps - but —

Here’s one approach for specifying images for the html plugin and referencing those ‘same’ images at their hosted URL for the creation of the image widgets. 

https://github.com/miroapp/app-examples/tree/master/drag-and-drop

 

I mimicked it to build this icon drag-n-drop app. Like that example, I hosted images at a same CDN in the same directory where the app pages/code is served.  

Reply