Is there a simple way to determine whether an image is outside or inside the textFrame?
I feel so complicated now.
var d = app.activeDocument;
var item = d.selection[0];
if (item.constructor.name == 'Rectangle' && 'TextFrame' == item.parent.parentTextFrames[0].constructor.name) {
var curFrame = item.parent.parentTextFrames[0];
alert(curFrame);
imgFitFrame(item, curFrame);
}I feel so complicated now.
When selecting an image, I want to get the text box where the image is located. But it's strange that when I select an image outside the box, there will be an error, and it should not have any response at this time.
At this point, 'item. parent. parentTextFrames [0]' does not exist and prompts' illegal '. What should I do?

