cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User
Super User

Re: Display attached images

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

4 REPLIES 4
Highlighted
Super User
Super User

Re: Display attached images

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Microsoft
Microsoft

Re: Display attached images

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

Highlighted
Regular Visitor

Re: Display attached images

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 

Highlighted
Super User
Super User

Re: Display attached images

@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. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,650)