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

How to add an image in a custom email post function

Mihai_Perdum June 19, 2019

Our JIRA instance is closed off from the internet, and I ended up having to store our logo asset on the server itself. The problem is that I can't use the absolute reference anywhere.

Any support on this it would be great.

What I am using inside my email custom notification code is :

 

"<img src=\"opt/atlassian/jira-lib/image.jpg\" alt=\"img\" width=\"100\" height=\"40\"/> "

 

1 answer

0 votes
Ilya Turov
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.
June 19, 2019

I clicked on my jira logo (the one in the top left corner) and it had path like this:

http://MYJIRA/images/icon-jira-logo.png

so i found out where the logo file is located, for me it was 

/opt/jira/atlassian/jira/atlassian-jira/images

so i just threw my file there and added it like this

(i didn't send the email, but preview showed the file so I fell positive)

<img src="http://MYJIRA/images/myTestFile.png" alt="img" width="100" height="40">
Mihai_Perdum June 19, 2019

Hello Ilya, you coming to save me on pinch is amazing. Can you plese tell me if access the reference from /opt/jira/atlassian/jira/atlassian-jira/images OR are you doing it by referencing the HTTP URL?

Ilya Turov
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.
June 19, 2019

I just searched my jira folder for icon-jira-logo.png, if you have jira installed on linux there's sure some console comand to do it. That's how I got that path.

Mihai_Perdum June 19, 2019

So is that using 

<img src="http://MYJIRA/images/myTestFile.png" alt="img" width="100" height="40">

 

or by using the /opt/jira/atlassian/jira/atlassian-jira/images ?

 

Sorry, but I just want to make sure.

 

And if I want to access the server instance directly, what would you say would be the best to do this inside the 

<img src=" .... ?

Ilya Turov
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.
June 19, 2019

Images that are in a special "images" folder (the one where icon-jira-logo.png is) can be accessed by path URL http://MYJIRA/images/myTestFile.png

so you need to find that folder and reference images with "default" method

Mihai_Perdum June 19, 2019

So, going for http://MYJIRA/images/myTestFile.png won't work. Our instance is protected. If I access in a normal browser the $baseurl/images/myTestFile.png it will work. But in the email, apparently I think it might be the cause given that the base URL does not contain www as well, the link is always broken.

 

Is there no other way other than doing it like using: http://MYJIRA/images/myTestFile.png?

Mihai_Perdum June 19, 2019

So if I wanted my img src to go for: /opt/jira/atlassian/jira/atlassian-jira/images, the path of the server directly, how would I have to go about it?

Ilya Turov
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.
June 19, 2019

yeah, guess I was too extatic about finding the solution so fast

I feel like you can't do it exactly like you intend, because it won't automatically attach it to the message anyway. 

so you either need to upload it to some server that can be seen from both in and out of your company and then do src stuff with url, or do some encodeBase64 magic (or CID appending) as described here:

https://medium.com/@emailmonks/top-expert-tips-on-how-to-embed-images-in-html-emails-4f13b3784472

Mihai_Perdum June 19, 2019

I have tried with base64 encodding but the support for that is rather ... disastrous. I haven't tried CID appending yet. Hey thank you for quickly replying to my question! Really appreciate it.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, team '25, conference, certifications, bootcamps, training experience, anaheim ca,

Want to make the most of Team ‘25?

Spend the day sharpening your skills in Atlassian Cloud Organization Admin or Jira Administration, then take the exam onsite. Already ready? Take one - or more - of 12 different certification exams while you’re in Anaheim at Team' 25.

Learn more
AUG Leaders

Upcoming Jira Events