Get attachment link from post ID or attachment ID


Well-known member
Is it possible (if possible, is there any guide) to get the link to the attachment(s) from the post/attachment ID?
Last edited:


XenForo developer
Staff member
The xf_attachment table has the attachment ID as the primary key, if you have that ID. Within that, there are content_type and content_id columns. The content type here would be "post" (and the content ID is the post ID).