Copy link to clipboard
Copied
Hi all,
When there's an image in a graphic frame (a linked file), you can find out the file name, path, etc. But how do you check if that frame is empty?
The following script brings up the Link found message when there's a linked file in the frame, but doesn't bring up the Not found message if there isn't. It brings up an "object is invalid" error.
Any ideas?
if (app.selection[0].graphics[0].itemLink.filePath != null) {
alert("Link found");
}
else {
alert("Not found");
}
if (!app.selection[0].graphics.length) { //no graphic in frame }
Copy link to clipboard
Copied
if (!app.selection[0].graphics.length) { //no graphic in frame }
Copy link to clipboard
Copied
Well, so deceptively simple. Thank you, Brian.
Copy link to clipboard
Copied
You're welcome. The important distinction is that the Link object is a child of the Graphic object.
Copy link to clipboard
Copied
Hi @JustyR ,
depending on what you have selected you like to see deeper into your selected objects to get all the graphics there. Imagine you selected a group that contains some graphics.
For this purpose you could explore the contents or the length of the allGraphics array.
If it is 0 , you know that there is no graphic at all in your selected object.
Note, that if you select text and the text contains anchored images or a table with graphic cells that contain graphics the allGraphics array will also get them.:
alert( app.selection[0].allGraphics.length );
Another example: When a selected text frame contains overset text with anchored graphics, allGraphics will also collect them. Even if the graphics are in the overset text.
Regards,
Uwe Laubender
( Adobe Community Professional )