Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Display a local image in an extension object?

I can display a div in an extension object with a hot-linked image from the web easily enough:

Qva.AddExtension('ShowImage', function() {

          this.Element.innerHTML = "<div style='width=200px; height:200px; background-image:url(http://www.some.image.jpg)'></div>";

});

But does anybody know how to show an image held locally inside the extension folder (i.e. sitting alongside your definition.xml, script.js and Icon.png)? I've been playing around without success and can't find any documentation or examples. I was hoping CSS 'background-image:url(local-image-in-extension-folder.jpg)' would work, but diesn't seem to.

Thanks!

1 Solution

Accepted Solutions
Brian_Munz
Employee
Employee

Hi,

In all of my extensions I set a variable called path to use for locally stored images and things:

var path = Qva.Remote + "?public=only&name=Extensions/ShowImage/";

So you would adjust your code to be:

this.Element.innerHTML = "<div style='width=200px; height:200px; background-image:url(" + path + "some.image.jpg)'></div>";

View solution in original post

7 Replies
Brian_Munz
Employee
Employee

Hi,

In all of my extensions I set a variable called path to use for locally stored images and things:

var path = Qva.Remote + "?public=only&name=Extensions/ShowImage/";

So you would adjust your code to be:

this.Element.innerHTML = "<div style='width=200px; height:200px; background-image:url(" + path + "some.image.jpg)'></div>";

Not applicable
Author

Awesome, thanks Brian! That works

andrefpc
Partner - Creator II
Partner - Creator II

Brian I have to develop a strategic map based on the balanced scorecard, I was thinking of your org chart as basis for that, can you give me some pointers on how to add custom images to that chart (like the led images inluded in QV)?

Thanks in advance.

warfollowmy_ver
Creator III
Creator III

bmz, how can I connect a folder from another server?

\\other_server\folder\

Because I can use external sources via http, can I also receive data from another server as locally?

Brian_Munz
Employee
Employee

You should be able to reference files from another location as long as they're accessible from wherever your extension is running.

Brian_Munz
Employee
Employee

Actually, not sure I understand your question.  What do you mean by "receive data" from another server?  Do you mean that you want to call out to another server and pull data into the extension to display there?  That should definitely be possible.

warfollowmy_ver
Creator III
Creator III

Thank you, the case is closed.

Re: Connect a folder from another server