cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kubalaml
Helper II
Helper II

Embed User Photo in SharePoint Rich Text Field

I'm trying to write to a rich text field in SharePoint from PowerApps. I'm writing the following to the field:

 

<table><tr><td><img src=""" & User().Image & """ /></td><td>" & User().FullName & "</tr></table>

 

The User().Image converts the picture to base64 correctly: "data&colon;image/png;base64,iVBORw0KGg ....", but when this is written to the rich text field, it gets written as 

 

<img data-themekey="#" alt=""/>

 

Why is SharePoint or PowerApps converting my img tag and removing the picture?

 

If I take the actual base64 image tag and manually enter it into the rich text field, it shows up correctly so I know this can work, but there is something weird going on with the Patch call. 

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @kubalaml ,

Could you please share a bit more about your scenario?

Do you want to embed an image data from your app into the Rich Text field in your SP List?

 

Based on the issue that you mentioned, I have made a test on my side, if you want to embed an image data from your app into the Rich Text field in your SP List, I afraid that there is no way to achieve your needs in PowerApps currently.

 

Actually, when you attach image into the Rich Text field in your SP List manually, there are two options for you to select -- From Computer and From Address:

10.JPG

 When you choose "From Computer" option to select a image from your local PC, it would also ask you to provide a proper Destination Library (SP Library in same SP Site) as below:

11.JPG

 After you save the record, and view it in your app, the Rich Text field would like below:

12.JPG

In other words, when you upload your image from your local PC, the uploaded image would be saved into the specific SP Library, then the Rich Text field refer to the URL Link of image stored in your SP Library rather than from your local PC. So there is no direct way to embed an base64 image data into the Rich Text Field from PowerApps app currently.

 

If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

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.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @kubalaml ,

Could you please share a bit more about your scenario?

Do you want to embed an image data from your app into the Rich Text field in your SP List?

 

Based on the issue that you mentioned, I have made a test on my side, if you want to embed an image data from your app into the Rich Text field in your SP List, I afraid that there is no way to achieve your needs in PowerApps currently.

 

Actually, when you attach image into the Rich Text field in your SP List manually, there are two options for you to select -- From Computer and From Address:

10.JPG

 When you choose "From Computer" option to select a image from your local PC, it would also ask you to provide a proper Destination Library (SP Library in same SP Site) as below:

11.JPG

 After you save the record, and view it in your app, the Rich Text field would like below:

12.JPG

In other words, when you upload your image from your local PC, the uploaded image would be saved into the specific SP Library, then the Rich Text field refer to the URL Link of image stored in your SP Library rather than from your local PC. So there is no direct way to embed an base64 image data into the Rich Text Field from PowerApps app currently.

 

If you would like this feature to be added in PowerApps, please submit an idea to PowerApps Ideas Forum:

https://powerusers.microsoft.com/t5/Power-Apps-Ideas/idb-p/PowerAppsIdeas

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.

View solution in original post

Thanks for the reply. In response to your question "Do you want to embed an image data from your app into the Rich Text field in your SP List?", the answer is Yes. Specifically, I was looking to embed the user's photo using User().Image. I noticed that this returns a base64 string and typically you could pass in a base64 string to the src attribute of an img tag and have it display the image. That doesn't work here because either PowerApps or SharePoint is removing the base64 string. 

 

As you suggested, the only way to get this to work is to use an actual image location for the src attribute so I went with plan B and used the user's photo location. I used the following in my Patch call and it worked!

 

"<img src=""https://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email=" & User().Email & "&UA=0&size=HR48x48" />"

 

For the "HR48x48" part, you can use 48, 96 or just leave it out. Those are the only options I got to work. 

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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