cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
imrineeman
Regular Visitor

Display attached images

Hello,

I want to display in gallery an image that the user has attached on form, as a sort of thumbnail

Preferably, the user will have Attachments and Upload a picture separately on form, if this is impossible then to view the first attached file as image

 

I tried for a few hours to get it to work to no avail

 

Thank you!

 

@RandyHayes 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@imrineeman 

If you've got the image in the attachments, you should be able to assign that to an image in your Gallery.

Put an Image control in your Gallery template and set the formula of the Image property to : 

   First(ThisItem.Attachments).AbsoluteUri

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

4 REPLIES 4
RandyHayes
Super User
Super User

@imrineeman 

If you've got the image in the attachments, you should be able to assign that to an image in your Gallery.

Put an Image control in your Gallery template and set the formula of the Image property to : 

   First(ThisItem.Attachments).AbsoluteUri

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
v-qiaqi-msft
Community Support
Community Support

Hi@imrineeman,

Based on the issue that you mentioned, do you want to display both the first attached image and the latest image you upload?

If you just want to display the first attached image, @RandyHayes posts the correct formula.

Insert an Image control to the Gallery and set the Image property as below

 

First(ThisItem.Attachments.Value).Value

 

If you want to display both the first attached image and the latest image you upload, you should insert the second Image control to the Gallery, and set the Image property as below

 

Last(FirstN(ThisItem.Attachments,2)).Value

 

Note: If you want to display the latest uploaded image, you should submit the form, and then it will be shown in the gallery.

071401.png

Best Regards,

Qi

Best Regards,
Qi

Hello, This works

Only problem im having is that files are sorted alphabetically at the attachment section - can i sort them by last added so that always the first \ last file show as image?

 

@RandyHayes 

@imrineeman 

So you're stating that you have multiple attachments and you only want to display the last one in it?

Although the Attachment property is in fact a table of attachment items, It doesn't have an normal ID to it or any other qualifying sequence.  So, you could certainly sort based on the fact that it is a table, but there is nothing to sort by.

I would recommend that if you need sorting on it, that you create your own naming of the attachment when it is added.  So, for example, you could prepend the name with the date in a yyyymmdd format, and then you can sort on that to find the last one.  Or use a sequence number to add to the file name - Text(CountRows(theRecord.Attachments)+1, "00") & originalFilename.  Then you will have a prepended sequence number.

Not much other way to work around that one.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,288)