Unable to load image in plugin VM file.

Ed Sattar April 24, 2014

I am writing a plugin . In that plugin i have a image folder src/main/resources/images

I have defined web resource

<web-resource key="calendar-resources" name="calendar Web Resources">
    <dependency>jira.webresources:global-static</dependency>
    <resource type="download" name="images/" location="images/"/>
    <context>atl.general</context>
</web-resource>

In my velocity file i m referring an image

<img src="images/blank.gif" width="16" height="16" />

Image is not loading.

Thanks!

1 answer

1 vote
Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2014

Use this in the velocity template.

$requestContext.baseUrl/download/resources/${your_plugin_key}:calendar-resources/images/blank.gif

Jobin Kuruvilla [Adaptavist]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2014

Change the plugin key as appropriate ;)

Manoj Gaikwad March 24, 2017

Hi Jobin,

Above solution work perfect for JIRA Plugin but I am trying same thing on Confluence Plugin, it shows broken image.

atlassian-plugin.xml - 

<web-resource key="MSSsoConfluencePlugin-resources" name="MSSsoConfluencePlugin Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="ConfluenceSSOAdminConfiguration.css" location="/css/ConfluenceSSOAdminConfiguration.css"/>
<resource type="download" name="ConfluenceSSOAdminConfiguration.js" location="/js/ConfluenceSSOAdminConfiguration.js"/>
<resource type="download" name="images/" location="images/"/>

<context>MSSsoConfluencePlugin</context>
</web-resource>

on .vm file - 

<img src="$urlPrefix${req.serverName}:${req.serverPort}/download/resources/com.microsoft.MSSsoConfluencePlugin:MSSsoConfluencePlugin-resources/images/copyIcon.png" alt="CopyIcon"/>

plugin key - com.microsoft.MSSsoConfluencePlugin

Only missing thing I can see is 
<dependency>jira.webresources:global-static</dependency>

What shoul be dependancy for Confluence plugin ? Can you please help me on this ? Really appreciate your quick help.

Suggest an answer

Log in or Sign up to answer