Skip to main content
Question

createImageAsync not working


Andre_Cassal

I’m getting a weird bug, i’m using createImageAsync within a widget (placed in Figma, not FigJam) and loading an external image. after browsing docs and changing the manifest to contain ‘allowDomains’… it still doesn’t work.

the weird part is looking at the console I can see the image loaded correctly.

in the code I’m using async/await within try/catch… but no error is thrown out.

any suggestions?

piece of the code below
image

Network tab in console

This topic has been closed for comments

4 replies

tank666
  • 4863 replies
  • August 3, 2023

What exactly is the bug? I see that you are loading the image but not applying it to the node fill. Should be imageHash: img.hash.


Andre_Cassal

yep… the function is not returning even the promise…

in the console… the promise is being returned and an Image object with hash is being returned after the promise is fulfill


tank666
  • 4863 replies
  • August 3, 2023

Sorry, but I can’t confirm this. I have tried pointing the URL to PNG, JPG, SVG and Data URI (Base64 PNG) files. This method returns an Image object for PNG, JPG URLs and Data URI. For SVG URL, the catch block is triggered and the “Image type is unsupported” error is displayed.


Andre_Cassal

not really a bug…

the problem was that the widget was not waiting for the async/await… it started working once I imported ‘waitForTask’ and converted by code block into a Promise.


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