@cschweden – additionally to that what Trevor said and posted:
You can look at every frame that is anchored in two different ways:
1. You can select it with the Text Tool. So consider it as a single character; a special character of course.
2. You can select the frame with the Selection Tool or the Direct Selection Tool. So now it is something like a rectangle, oval, polygon, text frame, that is anchored in the text.
If we do a GREP search, we look at the text level. So #1 will apply here. And happily GREP is providing a special notation for anchored objects (equal what they are): ~a
If one of these objects is found, a single character, it is indeed containing the fully anchored object.
You can easily find that out, if you do the following:
Have some text with an anchored object in it.
Select the anchored object with the text tool. That means select the special character that represents this object in the Story.
Now run the following code from the ESTK (ExtendScript Toolkit):
var myAnchoredThing = app.selection[0].texts[0].pageItems[0].getElements()[0]; $.writeln(myAnchoredThing);
The result would be [object Rectangle] , if you anchored a rectangle.
In case you want to add an hyperlink to the container object of an image itself, you're done. You found the object you have to deal with. In case you want dig deeper and working with the image or the images, or the graphic or the graphics inside that container, you have to go a step further.
You now do a loop through the allGraphics array of that object. In case this rectangle is itself holding a group of images pasted inside, there may be more than one images or graphics inside you want to hyperlink:
var myAnchoredThing = app.selection[0].texts[0].pageItems[0].getElements()[0]; var myGraphics = myAnchoredThing.allGraphics; for(var n=0;n<myGraphics.length;n++){ //DummyCode addHyperlinkForGraphic(myGraphics[n]); }; //DummyCode that writes the names of the graphics to the JavaScript Console of the ESTK //Could fail, if there is no itemLink, because a graphic was pasted inside the document! function addHyperlinkForGraphic(aGraphic){ $.writeln(aGraphic.itemLink.name); return; };
Uwe