Going Stellar

Home/Jira formatting reference

Jira text formatting

Attachment links in Jira: [^file] in wiki markup and ADF

[^name.ext] links to a file attached to the current work item. ADF stores attachments as media nodes in a mediaGroup, and an ADF media node needs a real file id from the media service.

Wiki markup

[^attachment.ext]

Stored as ADF (REST API v3)

The ADF document Jira Cloud stores for [^attachment.ext]:

{
 "type": "doc",
 "version": 1,
 "content": [
  {
   "type": "mediaGroup",
   "content": [
    {
     "type": "media",
     "attrs": {
      "type": "file",
      "id": "UNKNOWN_MEDIA_attachment.ext",
      "collection": ""
     }
    }
   ]
  }
 ]
}

Examples

Wiki markup (API v2)

[#anchor]

A same-page link, shown for comparison. It needs no attachment, so it renders as a link.

Rendered by Jira (HTML)

<p><a href="#anchor" rel="noreferrer">anchor</a></p>

Back to wiki after the round trip

[#anchor|#anchor]

Sent to Jira Cloud on .

Wiki markup (API v2)

[Anchor link|#anchorname]

The same form with an alias.

Rendered by Jira (HTML)

<p><a href="#anchorname" rel="noreferrer">Anchor link</a></p>

Back to wiki after the round trip

[Anchor link|#anchorname]

Sent to Jira Cloud on .

Wiki markup (API v2)

[Atlassian|http://atlassian.com]

An external link with an alias, as an alternative when the file is hosted elsewhere.

Rendered by Jira (HTML)

<p><a href="http://atlassian.com" class="external-link" rel="nofollow noreferrer">Atlassian</a></p>

Back to wiki after the round trip

[Atlassian|http://atlassian.com]

Sent to Jira Cloud on .

What changes in conversion

  • The probe for [^attachment.ext] ran on a work item with no attachment of that name. Jira rendered an error span and stored a mediaGroup with a placeholder id.
  • Sending that stored ADF back through v3 was rejected with ATTACHMENT_VALIDATION_ERROR, so an attachment link cannot be rebuilt from the placeholder.
  • The link text of an attachment link in the editor depends on the media service, which wiki markup cannot reproduce.

Pitfalls

  • The attachment must exist on the same work item before the link is rendered. Otherwise the rendered text is an error.
  • The link points to an attachment of the current work item only. Attachments on other work items need a full URL.

Sources

  1. Text Formatting Notation Help (Jira, in-product help)
  2. Atlassian Document Format: document structure (Jira Cloud platform)

Markdown version · All formatting pages