It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

how to know the total attachments of a page?

Bryan Echegoyen May 24, 2012

I need to know howmany files attached has a page...

exists any variable for this???


4 answers

0 votes
Renjith Pillai May 24, 2012

Could you explain what you need to achieve? Plugin?

REST API do gives the count of attachments for a page.

0 votes
Bryan Echegoyen May 24, 2012

inside the principal decorator... is there something like $sitemeshPage or anything ???

0 votes
Matthew J. Horn May 25, 2012

The AbstractPage has a getAttachments() method on it that you could probably use. It returns a List. You could then just get the number of items in the List. What little doc there is on the method says "Don't use it directly, use AttachmentManager.getAttachments(page) instead"

According to this page (, you can use $attachmentManager to get a reference to the AttachmentManager. The AttachmentManager has a method called countLatestVersionsOfAttachments() that appears to do exactly what you want.


Bryan Echegoyen May 25, 2012

nope, Those options doesn't work... :( I need to know how many attached files have the page, inside the main layout...

0 votes
Matthew Cobby Sep 26, 2012

How do you want to use this variable?

You can display it on a page by writing a user macro & accessing the velocity context.

## Macro title: Attachment download Path
## Macro has a body: N
## Developed by: Matthew Cobby

## Get basic manager objects first

## Get the Page manager & the target page

Number of Attachments: $numAttachments;

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

Confluence CVEs and common questions

Two vulnerabilities have been published for Confluence Server and Data Center recently: March 20, 2019 CVE-2019-3395 / CVE-2019-3396 April 17, 2019 CVE-2019-3398 The goal of this article is...

943 views 0 19
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you