Attachment Picker

ID: attachment-picker

The attachment-picker field type renders a modal picker for an attachment.

Definition configuration:

{
    "type": "object",
    "_attachment": {
        "id": "default"
    }
}

Form configuration:

{
    "type": "attachment-picker"
}

Create a Document with an Attachment

Define a content model with an attachment-picker field:

Preview content model:

Create a content instance:

Then the document will be created, and since the attachment's id is "default", the document's thumbnail is generated with the attachment:

Now the document's json looks like this:

{
    "title": "Animal Farm",
    "book-attachment": {
        "id": "default",
        "name": "animal-farm.jpeg",
        "size": 6881,
        "contentType": "image/jpeg"
    }
}

Replace an Attachment

Go to Edit Properties page and click Upload... button, choose a different file then save:

Now the attachment is replaced and the JSON is updated with the new attachment's information:

{
    "title": "Animal Farm",
    "book-attachment": {
        "id": "default",
        "name": "animal-farm2.jpeg",
        "size": 20502,
        "contentType": "image/jpeg"
    }
}

Delete an Attachment

Go to Edit Properties page and click Clear button, then Save:

The attachment is removed and the document icon is simply a generic icon.