In your situation, how about the following sample script?
function myFunction() {
const doc = DocumentApp.getActiveDocument();
const selection = doc.getSelection();
if (!selection) return;
selection.getRangeElements().forEach(e => {
const ele = e.getElement();
const type = ele.getType();
if (type == DocumentApp.ElementType.TEXT) {
doc.addBookmark(doc.newPosition(ele, e.getStartOffset()));
} else if (type == DocumentApp.ElementType.INLINE_IMAGE) {
doc.addBookmark(doc.newPosition(ele.asInlineImage().getParent(), 1));
}
});
}