Home/Confluence storage format reference
Confluence storage format
Links to attachments in Confluence storage format
An attachment link is an ac:link containing ri:attachment with the file name. Confluence has no ADF link mark for it, so the Cloud editor rewrites it as a view-file macro, which changes how the file appears. A file that cannot be found gives an unresolved link or a macro error.
Storage format
<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>
As ADF (Confluence Cloud)
The ADF that Confluence Cloud builds for:
<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>
{
"type": "doc",
"content": [
{
"type": "paragraph",
"content": [
{
"type": "mediaInline",
"attrs": {
"id": "UNKNOWN_MEDIA_ID",
"collection": "",
"__fileName": "atlassian_logo.gif"
}
}
]
}
],
"version": 1
}
Examples
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>The attachment link example from the storage format page.
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>Showing an attached PDF with the view file macro, and what the page displays when the file 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 .
Storage format sent
<ac:image><ri:attachment ri:filename="atlassian_logo.gif" /></ac:image>An attached image placed with ac:image, which is the other way to refer to an attachment.
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 .
What changes in conversion
- An ac:link to an attachment is saved through ADF as a mediaInline node. Storage comes back as a view-file macro holding the same ri:attachment, with a version-at-save attribute added.
- The custom link text is lost in that step. The text Link to a Confluence Attachment does not return, and the macro shows the file by name.
- The view file macro itself survives the round trip unchanged, including its ri:attachment parameter.
Pitfalls
- An ac:link whose ri:attachment is not found renders as an unresolved link with a # address, with no error message, so the problem is easy to miss.
- The view file macro prints an error naming the file when the attachment is missing. The file name must match exactly, with its extension.
- In the runs, an ac:image of atlassian_logo.gif rendered with a download address, while the ac:link to the same name rendered as unresolved. Do not use the view of an attachment link to prove the file is found.
Related
- Attached images
- <ac:link> to a page
- Link bodies: plain text and rich
- <a href> external links
- Storage format vs ADF