Skip to main content
Solved

Replacing canvas placeholders with array of external images

  • January 5, 2022
  • 3 replies
  • 1071 views

Tom21

I have an array of remote images I want to fetch and pass into user selected placeholders. In the plugin UI I have image data, like…

const data = [ 
   {name: 'One', image: 'https://foo.com/img1.jpg'},
   {name: 'Two', image: 'https://foo.com/img2.jpg'},
]

I understand I need to fetch each one and convert to base64, along the lines of:

  fetch(url)
    .then(r => r.arrayBuffer())
    .then(a => new Uint8Array(a))

and then eventually parent.postMessage(...) with the data. But I don’t know the best way to grab the image data and prepare it to pass it through.

Best answer by Tom21

Thanks. I did see that and it was helpful. My issue was that wasn’t using .then() properly after calling the function that fetched the image. I was able to eventually get it working.

View original
This topic has been closed for replies.

Gleb
  • Power Member
  • January 5, 2022

Tom21
  • January 5, 2022

Thanks. I did see that and it was helpful. My issue was that wasn’t using .then() properly after calling the function that fetched the image. I was able to eventually get it working.


Gleb
  • Power Member
  • January 17, 2022

This topic was automatically closed after 11 days. New replies are no longer allowed.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings