Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Pico
Partner - Creator
Partner - Creator

Extension to Load Images from Media Library Based on Variable

Hi everyone,

I need to display different images based on the value of a variable. Unfortunately, the native "Text & Image" object doesn’t seem to meet my requirements.

Is there a way to load images from the media library depending on a variable (the variable will likely match the image names with a ".png" extension)?

I’ve come across extensions that allow the use of APIs or URLs, but my images are stored on my PC, and I'm not sure how I can share them via URLs (security policies).

Does anyone know of an extension that can help with this?

Thanks in advance for your help!

Labels (3)
2 Solutions

Accepted Solutions
cristian_dalsanto
Partner - Contributor III
Partner - Contributor III

Maybe I misunderstood your needs, anyway I was thinking about something like this.

In the data model you define a table containing the image path (sense content library), similar to this:

images:
LOAD * Inline [
name, url
MAN1, /content/lab/noun-man-7038300.png
MAN2, /content/lab/noun-man-7038323.png
MAN3, /content/lab/noun-man-7038334.png
]

and display it in a straight table

Screenshot 2024-07-24 at 12.23.58.png

 

If you need only one image, you can define a variable that retrieve the url image by a criteria:

for example vCurrentUserImage:

=IF(subfield(OSUser(), '=', -1) = 'cristian.dalsanto', '/content/lab/noun-man-7038300.png', subfield(OSUser(), '\', 2))

and showing it using the table:

Screenshot 2024-07-24 at 12.55.36.png

best regards,

Cristian

View solution in original post

Pico
Partner - Creator
Partner - Creator
Author

Thank you @cristian_dalsanto for your precious suggestions, they were really helpful.
Her is the solution we used:

All the images has been loaded into the Media Library,

Through the api 

 

https://tenant.region.qlikcloud.com/api/v1/apps/appId/media/list

 

we got the URLs of every image (see https://community.qlik.com/t5/Move-to-SaaS/Is-there-a-way-to-share-the-Media-Library/td-p/2456608).

Using the "Map" object, with 

  • Layer 
    • Label = tenant.region.qlikcloud.com
    • Format =Image, 
    • URL ='/api/v1/apps/APPID/media/files/$(=vImageName]).png'
  • Map setting - base map - none.

So we got a single image, based on a variable. No extension needed (even if it's a pretty strange procedure if you ask me, both the map object and the API to retrieve the images URLs)

We didn't use the map because, to show only one image at time, it wasn't aesthetically pleasing. 

View solution in original post

4 Replies
cristian_dalsanto
Partner - Contributor III
Partner - Contributor III

Hi @Pico ,

maybe you've already thought of this, but you could upload the images to the Qlik Sense content library and then display them with an extension or the native Sense table object.

regards,

Cristian

 

Pico
Partner - Creator
Partner - Creator
Author

  • with an extension: All the one I saw work with URL, not with Media Library. if you know one that works differently please let me know!
  • the native Sense table object. This one work by selecting the image as background (same as "text & Image" object), so you cannot select the image depending on a variable. If there is a way to make it work with variable I am all ears!

Note that I need one single object, cause I have 40+ images, so loading 40+ different objects (like "text & image" one) and using a visualization condition on all of them, it's not feasible!

Thank you very much

 

Edit: I'm assuming "Qlik Sense content library " and Media Library to be the same thing. If 'm wrong please tell me

cristian_dalsanto
Partner - Contributor III
Partner - Contributor III

Maybe I misunderstood your needs, anyway I was thinking about something like this.

In the data model you define a table containing the image path (sense content library), similar to this:

images:
LOAD * Inline [
name, url
MAN1, /content/lab/noun-man-7038300.png
MAN2, /content/lab/noun-man-7038323.png
MAN3, /content/lab/noun-man-7038334.png
]

and display it in a straight table

Screenshot 2024-07-24 at 12.23.58.png

 

If you need only one image, you can define a variable that retrieve the url image by a criteria:

for example vCurrentUserImage:

=IF(subfield(OSUser(), '=', -1) = 'cristian.dalsanto', '/content/lab/noun-man-7038300.png', subfield(OSUser(), '\', 2))

and showing it using the table:

Screenshot 2024-07-24 at 12.55.36.png

best regards,

Cristian

Pico
Partner - Creator
Partner - Creator
Author

Thank you @cristian_dalsanto for your precious suggestions, they were really helpful.
Her is the solution we used:

All the images has been loaded into the Media Library,

Through the api 

 

https://tenant.region.qlikcloud.com/api/v1/apps/appId/media/list

 

we got the URLs of every image (see https://community.qlik.com/t5/Move-to-SaaS/Is-there-a-way-to-share-the-Media-Library/td-p/2456608).

Using the "Map" object, with 

  • Layer 
    • Label = tenant.region.qlikcloud.com
    • Format =Image, 
    • URL ='/api/v1/apps/APPID/media/files/$(=vImageName]).png'
  • Map setting - base map - none.

So we got a single image, based on a variable. No extension needed (even if it's a pretty strange procedure if you ask me, both the map object and the API to retrieve the images URLs)

We didn't use the map because, to show only one image at time, it wasn't aesthetically pleasing.