Home/Confluence storage format reference
Confluence storage format
Attached images in Confluence storage format
An attached image is an ac:image containing ri:attachment with the file name. Confluence adds ri:version-at-save on save. The ADF form is a mediaSingle holding a file media node, with a collection named after the page id.
Storage format
<ac:image>
<ri:attachment ri:filename="atlassian_logo.gif" />
</ac:image>
As ADF (Confluence Cloud)
The ADF that Confluence Cloud builds for:
<ac:image><ri:attachment ri:filename="atlassian_logo.gif" /></ac:image>
{
"type": "doc",
"content": [
{
"type": "mediaSingle",
"attrs": {
"layout": "align-start"
},
"content": [
{
"type": "media",
"attrs": {
"__fileMimeType": "image/gif",
"id": "UNKNOWN_MEDIA_ID",
"collection": "contentId-<page id>",
"type": "file",
"__fileName": "atlassian_logo.gif"
}
}
]
}
],
"version": 1
}
Examples
Storage format sent
<ac:image><ri:attachment ri:filename="atlassian_logo.gif" /></ac:image>The attached image example from the storage format page.
Rendered view (HTML)
<span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" loading="lazy" src="https://your-site.atlassian.net/wiki/download/attachments/<page id>/atlassian_logo.gif?version=1&modificationDate=1795971932009&cacheVersion=1&api=v2" data-image-src="https://your-site.atlassian.net/wiki/download/attachments/<page id>/atlassian_logo.gif?version=1&modificationDate=1795971932009&cacheVersion=1&api=v2" data-unresolved-comment-count="0" data-linked-resource-id="<attachment id>" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="atlassian_logo.gif" data-base-url="https://your-site.atlassian.net/wiki" data-linked-resource-content-type="application/octet-stream" data-linked-resource-container-id="<page id>" data-linked-resource-container-version="116" data-media-id="UNKNOWN_MEDIA_ID" data-media-type="file"></span>Storage format after the round trip through ADF
<ac:image ac:align="left" ac:layout="align-start"><ri:attachment ri:filename="atlassian_logo.gif" ri:version-at-save="1" /></ac:image>Sent to Confluence Cloud on .
Storage format sent
<p><ac:link><ri:attachment ri:filename="atlassian_logo.gif" /><ac:plain-text-link-body><![CDATA[Link to a Confluence Attachment]]></ac:plain-text-link-body></ac:link></p>An ac:link to the same file, which is converted differently from the image.
Rendered view (HTML)
<p><a class="unresolved" href="#">Link to a Confluence Attachment</a></p>Storage format after the round trip through ADF
<p><ac:structured-macro ac:name="view-file" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="name"><ri:attachment ri:filename="atlassian_logo.gif" ri:version-at-save="1" /></ac:parameter></ac:structured-macro></p>Sent to Confluence Cloud on .
Storage format sent
<ac:structured-macro ac:name="viewfile"><ac:parameter ac:name="name"><ri:attachment ri:filename="doc.pdf" /></ac:parameter></ac:structured-macro>An attachment shown with a macro instead of an image, with a file that is not found.
Rendered view (HTML)
<div class="error">Error rendering macro 'viewfile' : Failed to find attachment with Name doc.pdf</div>Storage format after the round trip through ADF
<ac:structured-macro ac:name="viewfile" ac:schema-version="1" ac:macro-id="<id>"><ac:parameter ac:name="name"><ri:attachment ri:filename="doc.pdf" /></ac:parameter></ac:structured-macro>Sent to Confluence Cloud on .
What changes in conversion
- A save adds ri:version-at-save to the ri:attachment element, so the image is pinned to the attachment version at that time.
- The ADF form is a file media node with the file name, the mime type and a collection of the form contentId followed by the page id. The media id is a placeholder.
- An ADF save adds ac:align and ac:layout set to left and align-start, and leaves the ri:attachment element as it was.
- In the view, the img carries data attributes that identify the attachment, such as its resource id, version and type.
Pitfalls
- The file name has to match the attachment name exactly. When no attachment is found, a link to it renders as unresolved, and the view file macro prints an error with the name it looked for.
- ri:version-at-save is written by Confluence on save, so hand-written markup does not need it.
- The numeric ids in the view are specific to the site and the page, so they must never be copied into another page.
Related
- <ac:image> from a URL
- Image attributes
- Links to attachments
- Link bodies: plain text and rich
- Storage format vs ADF