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 (https://developer.atlassian.com/display/CONFDEV/Confluence+Objects+Accessible+From+Velocity), 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.
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 email@example.com ## Get basic manager objects first #set($attachmentManager=$content.getAttachmentmanager()) ## Get the Page manager & the target page #set($attachmentsList=$attachmentManager.getLatestVersionsOfAttachments($content)) #set($numAttachments=$attachmentsList.size()) Number of Attachments: $numAttachments;
Hello Community 👋🏼 I’m Makisa, a product manager on Confluence Server and Data Center. Confluence Server & Data Center 7.0, our latest platform release, is now available and we wanted to shar...
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