How to place image programmatically into selected frame?

To not repeat myself: Issues with .duplicate into a new doc - #5 by Jarda