ImageFill Properties

First off, I’m loving the plugin support for XD. While it may not satisfy every need at this point, I think it’s headed in the right direction so congrats to the team!

For the plugin I’m working on, I need to get at the fileOrDataURI property of an ImageFill object. However, whenever I try to reference that property by name, I always get back undefined. The same goes for other properties like naturalWidth and naturalHeight.

I’ve also made sure the fill instance I’m looking at is in fact of type ImageFill (I did this by getting at the constructor.name property).

I must be doing something wrong. Any help is much appreciated. Thanks!

Hi @staufman,

fileOrDataURI is imageFill class’ parameter which can be used to create an imagefill. Since it’s not a property, you won’t be able to read it.

In regards to naturalWidth and naturalHeight, I couldn’t replicate what you saw. I was able to get those metrics like below:

let fill = new ImageFill(imageFile);
console.log(fill.naturalWidth)
// 545

Interesting. I’ll try the naturalWidth and naturalHeight properties again. That being said, is there any other way to get at the file path for the image asset?

Not really — although you can generate a rendition of the image to get a path to the representation. The image itself is embedded, so there’s no direct representation between image and a file entry.

See this tutorial for how to export renditions: https://adobexdplatform.com/plugin-docs/tutorials/how-to-export-a-rendition/?h=createrendition