Attachments Macro

The Attachments macro displays a list of files attached to a page.  

 It also allows users (with appropriate permissions) to:

  • upload a file to the page, directly from the list 
  • edit attachment properties and labels
  • delete an attached file (this deletes all versions of the file)
  • preview image attachments
  • download all files attached to the page. 

Note: you can use the macro parameters to turn off previews if you have very large attachments. 

Screenshot: the Attachments macro, showing details of an attachment

Using the Attachments Macro

To add the Attachments macro to a page:

  1. From the editor toolbar, choose Insert > Other Macros
  2. Find and select the required macro

Speed it up with autocomplete: Type and the beginning of the macro name, to see a list of suggested macros. In this example we're inserting the cheese macro.

To edit an existing macro: Click the macro placeholder and choose Edit. This will open the macro details, so you can edit the macro parameters.

Parameters

Parameters are options that you can set to control the content or format of the macro output. Where the parameter name used in Confluence storage format or wikimarkup is different to the label used in the macro browser, it will be listed below in brackets (example).

Parameter

Default

Description

Filename Patterns
(patterns)

all

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

Attachment Labels
(labels)
(none)A list of labels, used to filter the attachments to display. If you wish to enter more than one label, separate the labels with commas. Confluence will show only attachments that have all the labels specified. (The match is an AND, not an OR.) For information on labeling the attachments, see Add, Remove and Search for Labels.

Include Old Attachment Versions
(old)

false

A value of true will include previous attachment versions in the list.

Sort By
(sortBy) 

date

The sort order for attachments. Note that people viewing the page can change the sort order by clicking the column headings. Valid values are:

  • date – sorts by updated date in reverse chronological order (newest first)
  • size – sorts largest to smallest
  • name – sorts alphabetically
  • created date - sorts by creation date in reverse chronological order (newest first)
Sort Order
(sortOrder) 
ascendingUsed in combination with the Sort By parameter, to sort the attachments in ascending or descending order.

Allow Upload
(upload) 

true

If selected, the list of attachments will include options allowing users to browse for, and attach, new files.

Page Title
(page) 
(none)Used to display attachments from another page. If you do not enter a page title, the macro will display the files attached to the current page.
Show Previews
(preview) 
trueUsed to display a preview of the attached file. If true, preview will be visible when the list item is expanded.

Wiki markup example

This example is useful when you want to add a macro outside the editor, for example as custom content in the sidebar, header or footer of a space.

Macro name: attachments

Macro body: None.

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

Edit an attachment

There are a few ways to edit attachments in Confluence.

To edit a file from the attachments macro list:

  1. Click the arrow next to the file name to view its version history.
  2. Click Edit.
  3. Select the application in which you want to edit your file.
  4. Make your changes and then save your file in the desktop application.
  5. In Confluence, click Upload to confirm you want to save the edited file as a new version.

Learn more about editing files in Confluence.

Last modified on Sep 2, 2019

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.