Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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

Confluence Download Image Resource URL

I've scoured the mostly JIRA-centric entries about download resources, specifically trying to get URLs for images, get images to show, etc.

Figured it out how to do this with css a while back

        background: url('images/my-icon.png');
    vertical-align: middle;
            height: 16px;
             width: 16px;

but in this case I'm using the NotificaitionBuilder and I'm forced to find a way to get a relative/FQ path to the actual image.  When I look at the paths generated by the above css-based images, they're always in bundled resources which makes hardcoding that path untenable. 


This is what I think should work but does not:

String iconURL = webResourceUrlProvider.getResourceUrl("", "image.jpg"); <--generated a url but it's always broken link

Notification notification = notificationService.createOrUpdate(recipient, new NotificationBuilder()
            .actionIconUrl(iconURL) //<--has to be static.  can't css it. :(
            .iconUrl(iconURL) //<--has to go here.  can't css it. :(

    return notification;

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted

After much trial and this to work. Thanks to @Panos Karampis for the initial direction.


<web-resource key="myicons" type="download" name="DOESN'T SEEM TO MATTER" location="images/">
    <param name="content-type" value="image/png"/>


String iconURL =
                .getStaticPluginResourceUrl("", "images/some-icon.png", UrlMode.RELATIVE);

Atlassian JavaDoc

public abstract String getStaticPluginResourceUrl (String moduleCompleteKey, String resourceName, UrlMode urlMode)
This method returns a URL in either a relative or an absolute format, depending on the value of urlMode. See UrlMode for details of the different options for URL format. If a module with the given key cannot be found null is returned.
moduleCompleteKey complete plugin module key
resourceName the name of the resource as defined in the plugin manifest

Lessons Learned:

  1. Method getStaticPluginResourceUrl's "resourceName" parameter is misleading.  Suggest: "relativePathToResource" as I can name the web-resource whatever I want (see above example) and it won't work unless I give it a relative path to an image based on the moduleCompleteKey.
  2. <resource> resources are not included in the "webResourceUrlProvider" only <web-resources> as the name implies but that's a hard/time-consuming lesson to learn. sad

I am glad you made it. Documentation is a bit ugly sometimes and have to improvise smile

<web-item key="somekey" section="somesection" weight="10"><label key="text" />
<param name="icon" value="a resource here (grlupid.artifactid:key)" />


And then declare a resource as per value and parse the webitem. I cant write a descent answer with mobile... Sorry. 

I hope thats what you ask.

To parse the webitem use the WebInterfaceManager

final String[] tokens = webItem.getParams().get("icon").split(":");
final String moduleKey = tokens[0];
final String resourceName = tokens[1];
final DataSource source = dataSourceFactory.forPlugin(your plugin key).get().resourceFromModuleByName(moduleKey, resourceName).get();
new DefaultDataSourceFactory.NamedDataSource(source, webItem.getWebLabel().getKey());




Thanks, Panos, but your answer doesn't appear to be entirely complete.  

Why would one need to declare a web-item simply to obtain an icon image?  Is it actually necessary to split webitem tokens and use a mail service like dataSourceFactory?  

I've tried both these approaches.  Each time the webResourceUrlProvider.getResourceUrl() returns a path (no errors) but to nothing..

&lt;resource key="images" name="images/" type="download" location="images"/&gt;
&lt;resource type="download" name="ds-16.jpg" location="images/ds-16.jpg"&gt;
    &lt;param name="content-type" value="image/jpg"/&gt;

There's got to be a more straightforward way to accomplish this.

Hi Steve, I realize that my answer is based on my needs and is part of my production code, which makes it a bit more complicated than should. 

The webResourceUrlProvider has a bunch of methods and the one you are using does not 

"This method is not responsible for adding any static caching url prefixes." maybe the other methods give something more concrete?

So supposedly these should work but I've never got them to return anything but null.  Sigh.

String iconURL =
                .getStaticPluginResourceUrl("", "ds-16.jpg", UrlMode.RELATIVE);
String iconURL2 =
                .getStaticPluginResourceUrl("", "icon16", UrlMode.RELATIVE);

correlates to these to atlassian-plugin.xml resource declarations:

//iconURL1 - the standard image folder xml entry
&lt;resource key="images" name="images/" type="download" location="images"/&gt;
&lt;resource key="icon" type="download" name="icon16" location="images/icon-16.jpg"&gt;
    &lt;param name="content-type" value="image/jpg"/&gt;

I noticed that "moduleCompleteKey" is the first argument of "getStaticPluginResoucesUrl".  Does the resource have to belong to a module to work?  I'll try it.


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