Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

Using images from media in gallery view



We have created an app that shows every contact information of employees or our organization. We have created a gallery view that displays contacts names, phonenumber, address and an image of the person. Originally this image was picked from Office 365 data but we noticed some lag with loading the image when the app was in use. While not completely unusable we started seeking better way to load the images.


So what we have done so far is that we have uploaded some images to the Powerapps media. Next we tried to add an image to one contact using simple If-statement in the gallerys Image section:

If(DisplayName="Person Name1";'Person Name1';'Default Image')

NOTE: The image files are named after the employee as Firstname Lastname format.

This worked fine. However since we have many employees using If-statement or Switch-statement can cause a huge block of code:

     "Person Name1";'Person Name1';
     "Person Name2";'Person Name2';
     "Person Name3";'Person Name3';
     ........and so on till we get to the end and we can declare the default value
     'Default Image'

Now imaging if we have to do this for +80 personnel that is changing constantly. There's no way we can keep tracking what changes we have to do and changing the code isn't really a best practice.

Is there any easier way to get the image without using Office 365 data? We haven't been able to set the name from DisplayName in side ' '. And this is pretty much causing a lot of headache to us since we have to use ' ' to tell the app to use the image. If we only could put DisplayName inside ' ' somehow.

Community Support Team
Community Support Team

Re: Using images from media in gallery view

Hi @tuuman,

Could you please share a bit more about your scenario?

Do you want to display profile picture for the Employees of your Org in the Gallery using Media files in your app without using Office 365 data?

Based on the needs that you mentioned, I afraid that there is no direct way to achieve your needs in PowerApps currently.

As an alternative solution, you could consider take a try to save the Media Image files and corresponding Employee Name (DisplayName) into a Collection, then within the Gallery, you could use LookUp function to retrieve the corresponding image based on DisplayName of each employee.

I have made a test on my side, please take a try with the following workaround:9.JPG



Set the OnStart proeprty of the first screen of my app to following:

    {DisplayName: "Barry Cao", Image: 'Barry Cao'},
    {DisplayName: "charlie Liao", Image: 'charlie Liao'},
    {DisplayName: "dan he", Image: 'dan he'},
    {DisplayName: "Test2", Image: Test2},
    {DisplayName: "Kris Dai", Image: 'Kris Dai'}

On your side, you should type:

          {PersonName: "Person Name1"; Image: 'Person Name1'};
          {PersonName: "Person Name2"; Image: 'Person Name2'};
          {PersonName: "Person Name3"; Image: 'Person Name3'};

Set the Items property of the Gallery to following:


Within the Gallery, set the Image property of the Image control to following:

!IsBlank(LookUp(EmployeeImages, DisplayName = ThisItem.DisplayName, Image)),
LookUp(EmployeeImages, DisplayName = ThisItem.DisplayName, Image),

On your side, you should type:

!IsBlank(LookUp(EmployeeImages, PersonName = ThisItem.DisplayName, Image)),
LookUp(EmployeeImages, PersonName = ThisItem.DisplayName, Image),
'Default Image'

Best regards,


Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Level: Powered On

Re: Using images from media in gallery view

Thank you for your reply @v-xida-msft


Our original intend was to save images in media files and then call them in the gallery with certain names. What we thought we could do was to get ThisItem.DisplayName and inject that inside ' ' since the gallery image section required the usage of those single quotes. The problem is though if we put ThisItem.DisplayName inside ' ' Powerapps reads it as a file name and not as function call. If we put ThisItem.DisplayName without ' ' Powerapps reads it as a function but doesn't print image since DisplayName doesn't hold any. If we could somehow inject DisplayName inside ' ' we could achieve a much cleaner code that would automatically find corresponding image without the need of writing a new line of code. All what would left for us to is upload new image to the media.


Regarding to your workaround: Very interesting idea but ultimately it doesn't solve our problem. We still need to put huge amount code just to get collection. It would though clean up the code from the Gallery, but we could achieve same result with even less code by using Switch.


So ultimately what we want:

We want to get images without using Office 365 profile images. Therefore we added images to the mediafiles. We also want to make the code as short as possible by picking up name from DisplayName and search for corresponding image from media files. Only way we have succeed with this so far is creating If- and Switch-statements. Problem with these are they would be huge and end up being messy in the code. Creating collection would clean up the code from Gallery Image section but ultimately we still would have to manually input every item in the collection, making it huge and messy.


I hope this cleared a bit our situation.

Level: Powered On

Re: Using images from media in gallery view

I'm not marking solutions to this thread since I haven't received any solutions.

We decided to do workaround and just create bunch of Switch cases. It's not the prettiest or the most practical but it works the way we basicly want it. We're still open for other suggestions.

Helpful resources


Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.


Demo Extravaganza Championship Voting Open

Voting Ends: October 30, 2019!


Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020


Power Platform World Tour

Coming to a city near you


PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!


Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 197 members 5,058 guests
Please welcome our newest community members: