There are other manners to automate captions (checkbox on import, variable text + object and p-styles), but I thought I could get this to work and now at a loss. If someone has a moment to look at this, target the line myCaption.contents = <Metadata:Description></Metadata:Description>;
For if I was to use myCaption.contents = "caption text goes here"; you would be served placeholder text. I thought I would be closer to snagging the description, but no cigar as yet. 🙂
capset ();
function capset()
{
var
mDoc = app.activeDocument,
//anchored or grouped items excluded
myGraphics = mDoc.splineItems.everyItem().getElements(),
picContainer, gb, myCaption;
while(picContainer = myGraphics.pop() )
{
//exclude empty frames
if (!picContainer.graphics.length) continue;
gb= picContainer.geometricBounds;
//add a frame to to picture’s parent, which is a Page
myCaption = picContainer.parentPage.textFrames.add ();
//set position and size of the caption
myCaption.geometricBounds = [gb[2], gb[1], gb[2]+3, gb[3]];
//add placeholder contents
myCaption.contents = <Metadata:Description></Metadata:Description>;
mDoc.groups.add ([picContainer, myCaption]);
}
}