Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Add an Image to a velocity template

Jackson Farnsworth
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.
February 5, 2018

I'm trying to add an image to a velocity template in my plugin as described by atlassian here. I've added the web resource as so:

<web-resource key="navPics" name="navPics">
<resource type="download" name="defaultUserAvatar.png" location="com/onenetwork/servicedesk/testDashboard/images/defaultUserAvatar.png" />
</web-resource>

 And reference it in the vm file like so:

$webResourceManager.requireResource("com.servicedesk.testDashboard:navPics")
<style>
#avatar_ONE {
url(defaultUserAvatar.png);
height: 24px;
width: 24px;
}
</style>

Yet nothing shows up. What have I done wrong?

 

 

1 answer

0 votes
Hakeem Olasupo
Community Champion
November 20, 2021

For example, try this in your Velocity template file:

 

<img src="cid:${cid}" alt = "Foo">

 

Or in your Java code, try:

URL url = new URL("image.png");

String cid = email.embed(url, "Foo");

Map model = new HashMap();

model.put("cid", cid);

Suggest an answer

Log in or Sign up to answer