Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

JIRA Plugin Development | How to import image file on velocity file.

Tarr January 27, 2013

Hi Atlassian Answers,

I'm trying to make jira plugin. I want to image file in my velocity files but I couldn't do it.

The following is my way about it. Please, tell me how to import image files.

■atlassian-plugin.xml

<web-panel ...>

<resource name="view" type="velocity" location="post-to-yammer-button.vm" />

<resource type="download" name="images/" location="images/yam_btn.gif"/>

</web-panel>

■post-to-yammer-button.vm

...

<img src="images/yam_btn.gif">

...

■src path

dev-posttoyammer/src/main/resources/images/yam_btn.gif

(plugin home directory is dev-posttoyammer)

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
Answer accepted
ConradR
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.
January 27, 2013

This should work:

&lt;resource type="download" name="images/" location="images/"/&gt;
&lt;img src="$req.contextPath/download/resources/PLUGIN_KEY:RESOURCE_KEY/images/yam_btn.gif"&gt;

Tarr January 27, 2013

■pom.xml

&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
	&lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
	&lt;groupId&gt;dev.posttoyammer&lt;/groupId&gt;
	&lt;artifactId&gt;dev-posttoyammer&lt;/artifactId&gt;
	&lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
	&lt;organization&gt;
		&lt;name&gt;&lt;/name&gt;
		&lt;url&gt;&lt;/url&gt;
	&lt;/organization&gt;
	&lt;name&gt;Post-To-Yammer-Plugin&lt;/name&gt;
	&lt;description&gt;This plugin set up "post to yammer button" on issue page.&lt;/description&gt;
	&lt;packaging&gt;atlassian-plugin&lt;/packaging&gt;
	&lt;dependencies&gt;
		&lt;dependency&gt;
			&lt;groupId&gt;com.atlassian.jira&lt;/groupId&gt;
			&lt;artifactId&gt;jira-api&lt;/artifactId&gt;
			&lt;version&gt;${jira.version}&lt;/version&gt;
			&lt;scope&gt;provided&lt;/scope&gt;
		&lt;/dependency&gt;
	
	...
	
		&lt;properties&gt;
		&lt;jira.version&gt;5.0&lt;/jira.version&gt;
		&lt;amps.version&gt;3.11&lt;/amps.version&gt;
	&lt;/properties&gt;
&lt;/project&gt;

■post-to-yammer-button.vm

&lt;img src="$req.contextPath/download/resources/dev.posttoyammer.dev-posttoyammer:post-to-yammer-button/images/yam_btn.gif" /&gt;

Tarr January 27, 2013

Hi Conrad,

Thank you for your reply. I tried to modify with your advice but I couldn't work it. Where is my misstake?

■atlassian-plugin.xml

&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;atlassian-plugin key="${project.groupId}.${project.artifactId}"
	name="${project.name}" plugins-version="2"&gt;
	&lt;plugin-info&gt;
		&lt;description&gt;${project.description}&lt;/description&gt;
		&lt;version&gt;${project.version}&lt;/version&gt;
		&lt;vendor name="${project.organization.name}" url="${project.organization.url}" /&gt;
	&lt;/plugin-info&gt;
	


	&lt;web-panel name="PostToYammerButton" i18n-name-key="post-to-yammer-button.name"
		key="post-to-yammer-button" location="atl.jira.view.issue.right.context"
		weight="1000"&gt;
		&lt;description key="post-to-yammer-button.description"&gt;The PostToYammerButton Plugin
		&lt;/description&gt;
		 &lt;context-provider class="authe.IssueInfoProvider"/&gt;
		&lt;resource name="view" type="velocity" location="post-to-yammer-button.vm" /&gt;
		&lt;label key="post-to-yammer-button.title" /&gt;
		&lt;resource type="download" name="images/" location="images/"/&gt;
	&lt;/web-panel&gt;
	&lt;resource type="i18n" name="i18n" location="atlassian-plugin" /&gt;

&lt;/atlassian-plugin&gt;

ConradR
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.
January 27, 2013

Hm, I don't know. This works for me in a project-tabpanel. Did you deploy the plugin after your changes in atlassian-plugin.xml? What is the URL of the image and the return code?

Udit Verma November 20, 2014

Hi all, I'm facing the exact same issue. Please post, if you got the solution.

TAGS
AUG Leaders

Atlassian Community Events