web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Set default image in g...
Power Apps
Unanswered

Set default image in gallery if no attachment has been added to gallery item

(0) ShareShare
ReportReport
Posted on by 118

Hi, 

 

I want to use an image as default in a gallery based on the condition if there are any attachments included in the item. If yes, then I want to show the first image from this attachment. If no attachment has been added to the item, I want to use a default image. 

I gave the default image an OnSelect property = Set(varBild; No Attachment). Second is the image name uploaded to PowerApps.

 

I tried to implement the following Image property in the gallery: 
If(IsEmpty(First(ThisItem.Anlagen).Value);varBild;First(ThisItem.Anlagen).Value)

 

But the default image is not showing?! Where is the issue here? I would be thankful for support!

 

DirkKoch_1-1668433414327.png

 

Categories:
I have the same question (0)
  • cmitchener Profile Picture
    on at

    I believe the issue you are having is you used semicolons instead of commas. Try replacing it with this code:

     

    If(IsEmpty(First(ThisItem.Anlagen).Value),varBild,First(ThisItem.Anlagen).Value)

     

     

    P.S. If you aren't picky about the image that's in the field when there's no attachment, PowerApps has an item called "SampleImage", which just puts their default image in the field. It could save you some time and space on coding.

  • DirkKoch Profile Picture
    118 on at

    @cmitchener  No, the syntax is fine. We use ";" instead of ",". 

    The issue is something else.

  • cmitchener Profile Picture
    on at

    I see, my mistake. What I would try is temporarily replacing varBild with SampleImage to see if that will work, then that will at least tell you if the variable is correctly loading. You could also try adding apostrophes into the Set function to make it like so:

     

    Set(varBild; 'No Attachment')

     

    Let me know if this will work

  • DirkKoch Profile Picture
    118 on at

    @cmitchener same issue with SampleImage. No picture shown in gallery. Apostrophes were already used in the Setfunction.

  • cmitchener Profile Picture
    on at

    Interesting; maybe try using only First(ThisItem.Attachments).Value to see if that works. The app could be having trouble finding the data

  • DirkKoch Profile Picture
    118 on at

    After multiple attempts I managed to get it to work now.

  • cmitchener Profile Picture
    on at

    Oh good, I hope my input was at least a little bit helpful

  • clight Profile Picture
    27 on at

    I'm having same issue. What did you do to get it to work? 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 345 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 177

Last 30 days Overall leaderboard