SHARE

In this post i will look at dynamically loaded images and how these images may not appear in play mode.

Adding images to screens

In Power Apps studio it is easy to create in image control by selecting the Image control from the Media menu.

You can now Add you images by uploading them to the control or you can upload them within the media library of the app.

Dynamically loaded images in Power Apps are invisible 2

Now within the control you can select the image

Dynamically loaded images in Power Apps are invisible 3

That is easy.

Why create dynamically loaded images?

But how about if you want different images depending on your data. for example you want to show image1 when a number has been set to 1 and image 2 when a number has been set to 2.

Or maybe even show a red, amber or green image depending on a status value.

You might now create 3 image controls on top of each other and only make the one visible that you want. how about if you could just have one control and set the image to the image that you want.

Media URIs in Power Apps

Time to have a look at the way Power Apps references images.

I created an image and a label that displays imgImageControl.Image

Dynamically loaded images in Power Apps are invisible 4

The image uri will now be shown as the following uri in my label

appres://resources/Images1 Generating the Uri dynamically

Now I’ve added a label that holds a number in it. and I can use this number to generate the Uri using the expression:

“appres://resources/Image” & Number Dynamically loaded images in Power AppsImage visibility in play mode

When I now run the app in play mode I’m finding that my image doesn’t load! This is annoying.

Dynamically loaded images in Power Apps are invisible 5

Sp the power Apps player is doing different things than my Power apps development environment. That is not nice. You would expect that testing an app in the studio environment would be good enough , but it is not.

So when you get your users to use your app do make sure that you have tested the app in play mode first, as these dynamically loaded images may not appear.

I wonder how many other things there are that are loaded in this way as I have seen occasionally similar kind of issues.

Fixing to invisible images

I can see from my first label that the Uri of the image is set correctly however the image doesn’t appear.

How can i resolve this?

I added my images as separate controls on a separate screen. Then I reloaded my app and the image didn appear.

Why does this happen?

It looks like the app will load only those images that have specifically been used in the app. Some how Power Apps seems to ignore the images for which the name has been calculated.

Related

LEAVE A REPLY

Please enter your comment!
Please enter your name here