Skip to main content
frameexpert
Community Expert
Community Expert
September 23, 2013
Answered

How do I get the path to an image?

  • September 23, 2013
  • 1 reply
  • 742 views

I have an Image selected on the page. How do I get the path to the image? I see a "name" property but this just gives me a blank string. I am using CS6 and JavaScript. Thanks.

Rick

This topic has been closed for replies.
Correct answer frameexpert

I found what I was looking for:

var graphic = app.selection[0];

alert (graphic.itemLink.filePath);

1 reply

frameexpert
Community Expert
frameexpertCommunity ExpertAuthorCorrect answer
Community Expert
September 24, 2013

I found what I was looking for:

var graphic = app.selection[0];

alert (graphic.itemLink.filePath);

www.frameexpert.com
Inspiring
September 24, 2013

Just bear in mind that that code could prodce a non-filePath if the graphic doesn't have an itemLink or if the itemLink is in a bad state (I've not checked but I think there are cases where changing you code to the post to the temptingly simple:

myFile = File(graphic.itemLink.filePath());

could cause an error or could result in something that looks like a file but isn't.

Just be cautious.

Usually, when I'm writing link-centric code, I normally start with the Links collection rather than the objects that might or might not have itemLinks -- at the very least it saves processing time and it also makes it a lot easier to find them.

Well done finding the original answer.

Dave