A little more info and context would be helpful. For example, in which template do you want to „grab“ the attachment? Can there be more than one attachment in the first post? If so, can there be more than one image?
K, so you want to access the first attachment of the first post. That should be straightforward.. Would this custom template be included in another template?