Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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
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:
best regards,
Cristian
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
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.
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
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
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
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:
best regards,
Cristian
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
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.
@Pico wrote:
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?
I was messing around with something similar for a uni project where we built a dashboard to show different campus maps and resource pics based on what a student selected. The map object trick with the API urls worked out pretty solid once (you can check them out here) we got the variable matching the file names right. Kinda reminded me how much easier it gets when you can lean on solid resources during those heavy academic stretches. For anyone juggling school deadlines and tech stuff like this, checking out expert assignment support from real geeks makes a real difference cause they chat with you live and help break down the tough bits without just handing over finished work. Got me through a couple of data viz lessons in college where the library of materials felt endless and the tutors were stretched thin.
Thanks in advance for your help!
Yeah the map object workaround does the job for variable-driven images from the media library, but it's a bit of a hack and doesn't always look great for just one image.
Still seeing people use the straight table with image representation + the /api/v1/apps/.../media/files/ URL expression (variable or field in the filename) and it stays pretty clean. Same path pattern works fine.