Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,359,742
Community Members
 
Community Events
168
Community Groups

Show images (attachments) on a page, based on the labels on that page

Hi.

Is there a way to show specific images (attachments) based on the labels on a page?

It needs to be based on the labels on the specific page, NOT the images them selfs.

Anyone know of a way?

1 answer

0 votes
Andrii M Rising Star Sep 09, 2022

Hello @Mads Haugaard ,

As I know, this is NOT possible with platform macros, but this should be easy code to implement a custom macro or using a ScriptRunner script to get the list of such pages.

Example for a space pages with label 'TEST':

SpaceManager spaceManager = ComponentLocator.getComponent(SpaceManager.class);
Label label = new Label("TEST");
Space space = spaceManager.getSpace("SPACE_A");
List<Page> spacePages = space.getAllPages;
List<Attachment> attachments = new ArrayList<>();
spacePages.filter(page -> page.gtLabels().contains(label)).forEach(page -> {
List<Attachment> pageAttaches = page.getAtatchment();
attachments.addAll(pageAttaches);
});

return attachments;

 

Thanks

Thank you for the answer.

What I need is the som way to show images based on the labels on a page.

 

Ex.

A page has a label named "sunshine".

That page also has an attachment (image) named "sunshine.jpg" with the label "sunshine".

That image is automatically show on the above mentioned page.

If the label is removed from the page, then the image is no longer show.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
Community showcase
Published in Confluence

Watch 4 Confluence apps compete for Best App Demo in September's Appy Hours

Calling all collaborators! Appy Hours on the Atlassian Community is a monthly event where 4 Partner and app vendor presenters go head-to-head with 5-minute demos for the title of Best App Demo. I...

473 views 0 12
Read article

Atlassian Community Events