When you add Mediafiles (images, galleries, videos etc.) with the "Add Media Screen" in "Post Edit Screen" then the Attachment will get linked(parent_id) to the post/page.
I don't know if this is done while you select the Mediafile from the Library or after saving the post?
The problem is, I have created a shortcode which adds media to my post but those Mediafiles do not get linked to the post.
Has anyone an idea how to fix that?