Get url for <web-resource> specified in atlassian-plugin.xml using JS

Hello here, I’ve gone through several docs but can’t seem to figure how to specify a correct base url for abd <img /> created using Javascript. After specifying the and building the plugin, I’m not sure how I can dynamically (with JS) create an <img> who’s src points to my plugin assets folder already defined in by a <web-resource>.

I’ve noticed that the path to my JS looks someting like /confluence/s/d41d8cd98f00b204e98009988339323-CDN/en_GB/7901/NOCACHE/2.0.0-SNAPSHOT/_/download/resources/{artifact-id}:{resources-key}/{resource-name}.{ext}, and I can access this in the browser by substituting the{resource-name}.{ext}.

Is there a way to expose such resource path to my plugin.

Hi, I’ve found the way to formulate an URL to the images within the plugin.


e.g. if my atlassian-plugin.xml is

<atlassian-plugin key="" name="Confluence Search Plugin" plugins-version="2">
   <web-resource key="confluence-search-resources" name="confluence-search Web Resources">
      <resource type="download" name="images/" location="/images" />

and I have a file


then I can access this file from JS using the following URL


assuming the root context is /

Thanks for sharing Huyle.
I was able to solve this by specifying a <resource> for all my media file (it wasn’t part of a <web-resource>. Then I got the server url using SettingsManager
So it looks something like SettingsManager.getGlobalSettings().getBaseUrl()/download/resoursces/{artifactID}.{groupID}/{resource name}. Then I just passed this value to the JS (AJS).

For thouse who trying to do the same

Correct path is:

So, given :
file in project=src/main/resources/things/mypage.html
so, path-to-file will be just “mypage.html”

and web-resource described as folows:

<web-resource key="stuff" name="My Web Resources">
    <resource type="download" name="things/" location="things/"/>

resulting link will be:


1 Like