attach_media
Links an image or document to a person, event, or source, either by uploading a new file or reusing an existing Media object to avoid duplicate media.
Instructions
Attach an image or document to an object -- a new upload, or one already in the tree.
With file_path, the bytes are uploaded into the tree's managed media directory (so don't point at files you don't want copied); if that exact file is already present it is reused rather than duplicated. With media_ref, an existing Media object is linked.
One image should be ONE Media object, linked from each object it belongs to
and cited once per fact it proves. Uploading the same photograph separately
for the husband and the wife creates duplicates that have to be unpicked
later. The write is verified afterwards: verified: false means nothing
attached, whatever the rest of the result says.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | Yes | Object handle/gramps_id to attach media to. | |
| file_path | No | Absolute path to a local image, PDF, audio or video file to upload. Use this OR media_ref. | |
| media_ref | No | Handle or gramps_id of a Media object ALREADY in the tree. Prefer this when the same document supports several people. | |
| description | No | What the document IS, in archival terms. Only used when uploading a new file. | |
| target_type | No | Type of the target object: 'person', 'event', 'source', etc. | person |