Dear community!
What I am trying to do, is including an image over a script fragment. (On the issue overview page).
Using Script Fragments, I can create a new div element with an image in it.
However, I am only able to access the images in
JIRA_INSTALL_DIR/images
I am trying to find a way to provide images from JIRA_HOME however.
Has anyone an idea how to achieve that?
EDIT:
I am using a web resource (javascript) to add a picture to a specific place, f.e. in the issue view above the issue description, see code below.
(function ($) {
$(function () {
/**
* Binding is required for link such as
* http://localhost:8080/jira/projects/JRA/issues/JRA-4?filter=allopenissues
*/
JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (event, $context, reason) {
if (reason === JIRA.CONTENT_ADDED_REASON.pageLoad || reason === JIRA.CONTENT_ADDED_REASON.panelRefreshed) {
addLogo();
}
});
addLogo();
});
function addLogo() {
var projectKey = "PROJECTKEY";
var issue = JIRA.Issue.getIssueKey();
if (typeof (issue) !== "undefined") {
var currentProject = issue.substr(0, issue.indexOf('-'));
if (currentProject == projectKey) {
$("div.issue-body-content div.issue-main-column").prepend("<img id='theImg' src='/LOGO.png'/>");
}
}
}
})(AJS.$);
Thank you very much!
Best regards,
Alex
As a workaround you can Base64 encode your logo image and put the code directly in javascript.
There are numerous image encoders/decoders online, one of them http://freeonlinetools24.com/base64-image
The code you put in the javascript looks like this:
<img src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAO....' />
Hi Aliaksanr,
How are you currently accessing the images in the JIRA_INSTALL_DIR/images directory ?
I might be mistaken in thinking that a simple solution may be to retrieve the image you want using the Groovy method:
return new File(filePath)
If I have misunderstood the requirement please let me know and offer some more detail.
Thanks
Johnson Howard (Adaptavist)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi!
My question was not well explained, I have updated it.
In general I do not provide any images from the install directory, as those images are "provided" by Jira itself and can be easily accessed over the web, e.g.:
jira_url/issue/images/icons/priorities/major.svg
this picture is located in
/images/icons/priorities/major.svg in the install dir.
I want to include my own pictures in a similar way, but from the HOME directory, as you shouldn't put any custom files in the install dir.
Thanks!
Alex
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Alex,
I think I understand now. Your web resource will only find images that are placed in the JIRA_INSTALL_DIR/images, and won't work if you attempt to put the images in the HOME directory?
When you attempt to access them from the HOME directory do you put a fully qualified path? or just the file name, as you have in your js example.
Thanks
Johnson Howard (Adaptavist)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@JohnsonHoward, we can't really use ScriptRunner's web resources to add our own custom resources? When talking about resources I mean my custom images/icons. I.e. I want to use SR's web resources to load only only CSS/JS, but also PNGs.
At this time, I have to store my custom images under JIRA_INSTALL_DIR/atlassian-jira/images and load them via <img scr="/images/my_custom_image.png">.
However, this location is not good in case of future Jira upgrades therefore I'd like to have all my custom images stored somewhere under JIRA_HOME/scripts/resources where I have all my customizations.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.