List page attachments using injection via File Viewer macro

List page attachments using injection via File Viewer macro

Scenario

Use the File Viewer macro to report on attachments used in the current page.

The report lists all attachments on the page and shows a thumbnail preview.

If the page does not have any attachments, the message No files have been attached to this page will be displayed.

Result

Recipe

Apps

Reporting for Confluence Data Center

Level

Intermediate

Estimated time

5 minutes

Macros

Local Reporter, Report Block, Report Body, Report Empty, Report Info, Report Wrapper

Suppliers

Attachment Supplier, Content Supplier

Storage format

You can copy and paste this code into the Confluence Source Editor:

<ac:structured-macro ac:name="report-block" ac:schema-version="1" ac:macro-id="75916e18-eaf0-4808-80fc-27e8289165ef"><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:rich-text-body><ac:structured-macro ac:name="local-reporter" ac:schema-version="1" ac:macro-id="63bbf787-e471-422c-8eed-adb48d3f7895"><ac:parameter ac:name="">content:attachments</ac:parameter><ac:rich-text-body><br /></ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:name="report-body" ac:schema-version="1" ac:macro-id="f417d833-084d-4985-bc67-e3dbd256ef6c"><ac:parameter ac:name="injected">true</ac:parameter><ac:rich-text-body> <p><ac:structured-macro ac:name="report-info" ac:schema-version="1" ac:macro-id="fc895489-5a4d-4d6a-b33e-d36e003c67a4"><ac:parameter ac:name="link">true</ac:parameter><ac:parameter ac:name="">attachment:title</ac:parameter></ac:structured-macro>:</p><ac:structured-macro ac:name="report-wrapper" ac:schema-version="1" ac:macro-id="07199c33-5591-4b23-afee-ccc5ae5c3f89"><ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter><ac:rich-text-body> <p><ac:structured-macro ac:name="view-file" ac:schema-version="1" ac:macro-id="d0eb00d1-c1f4-4bd4-83f5-ccc15ef3aef0"><ac:parameter ac:name="name"><ri:attachment ri:filename="%attachment:title%" /></ac:parameter><ac:parameter ac:name="height">150</ac:parameter></ac:structured-macro></p></ac:rich-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro><ac:structured-macro ac:name="report-empty" ac:schema-version="1" ac:macro-id="39550162-0c25-45cc-b195-42be150b6a29"><ac:rich-text-body> <p><em>No files have been attached to this page.</em></p></ac:rich-text-body></ac:structured-macro></ac:rich-text-body></ac:structured-macro>

Macro structure

You can recreate the example in the editor view: