Attachments Macro

Displays a list of attachments on a given page. For more information see Displaying a List of Attachments.

Code examples

The following examples are provided for advanced users who want to edit the underlying markup for a Confluence page.

Macro name: attachments

Macro body: None.

Parameter name Required Default Parameter description and accepted values
old No false

Available values:

  • false - Displays only the latest version of each attachment.
  • true – Displays all versions of each attachment, including the old versions.
patterns No (None)

A comma-separated list of regular expressions, used to filter the attachments by file name. Note that the parameter values must be regular expressions. For example:

  • To match a file suffix of 'jpg', use .*jpg (not *.jpg).
  • To match file names ending in 'jpg' or 'png', use .*jpg,.*png

sortBy No date

Available values:

  • date
  • size
  • name
  • createdate
page No The page on which the macro exists. Page name, used to display attachments from another page.
sortOrder No

The default sort order is determined by the sortBy type:

  • Reverse chronological for 'date'.
  • Largest to smallest for 'size'.
  • Alphabetical for 'name'.

Available values:

  • ascending
  • descending
labels No (None) A comma-separated list of labels. Confluence will show only attachments that have all the labels specified. (The match is an AND, not an OR.)
upload No false Determines whether the list of attachments will include options allowing users to browse for, and attach, new files.
No true

Determines whether a preview of the attached file appears when the item is expanded.

Storage format example

<ac:structured-macro ac:name="attachments">
  <ac:parameter ac:name="old">false</ac:parameter>
  <ac:parameter ac:name="patterns">.*png,.*jpg</ac:parameter>
  <ac:parameter ac:name="sortBy">name</ac:parameter>
  <ac:parameter ac:name="page">
      <ri:page ri:content-title="My page about chocolate"/>
  <ac:parameter ac:name="sortOrder">descending</ac:parameter>
  <ac:parameter ac:name="labels">chocolate,cookies</ac:parameter>
  <ac:parameter ac:name="upload">false</ac:parameter>

Wiki markup example

{attachments:old=false|patterns=.*png,.*jpg|sortby=name|page=My page about chocolate|sortorder=descending|labels=chocolate,cookies|upload=false|preview=false}

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport