How to get SharePoint profile picture

Profile pictures allow you to easily identify users and on SharePoint there are a couple different ways to get it.

If you are developing SharePoint solutions and need to display profile pictures you can use one of the methods described below.

These methods are target for SharePoint online and they will not work for external users and for accounts without Exchange.

SharePoint Profile Picture

/_layouts/15/userphoto.aspx?size=L&username=joao@handsonsharepoint.com

Options:

  • Size=S | 48×48 px
  • Size=M | 72×72 px
  • Size=L | 300×300 px
  • Username – replace it by the user email you want to retrieve the photo

e.g.

 <img src="/_layouts/15/userphoto.aspx?size=L&username=joao@handsonsharepoint.com"/>


Outlook

https://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email=joao@handsonsharepoint.com&UA=0&size=HR64x64&sc=1538493608488

Options:

  • Email – replace it by the user email you want to retrieve the photo
  • Size=HR64x64 – This is the only size that worked for me, and it returns a poor image with 400×400 px.

e.g.

<img src="https://outlook.office365.com/owa/service.svc/s/GetPersonaPhoto?email=joao@handsonsharepoint.com&UA=0&size=HR64x64&sc=1538493608488  
"/>


Delve API

/_vti_bin/DelveApi.ashx/people/profileimage?size=L&userId=joao@handsonsharepoint.com

Options:

  • Size=S | 48×48 px
  • Size=M | 72×72 px
  • Size=L | 300×300 px
  • userId – replace it by the user email you want to retrieve the photo

e.g.

<img src="/_vti_bin/DelveApi.ashx/people/profileimage?size=L&amp;userId=joao@handsonsharepoint.com"/>


Delve URL

https://eur.delve.office.com/mt/v3/people/profileimage?userId=joao@handsonsharepoint.com&size=L

Options:

  • userId – replace it by the user email you want to retrieve the photo
  • Size=L – This is the only size that worked for me, and it returns a poor image with 400×400 px.

e.g.

<img src="https://eur.delve.office.com/mt/v3/people/profileimage?userId=joao@handsonsharepoint.com&size=L 
"/>

Depending of your region the Delve URL might be different if the image is not returned try the alternative ones:

  • https://nam.delve.office.com/
  • https://eur.delve.office.com/
  • https://delve-gcc.office.com/

My Site

All the user profile pictures are stored in the User Photos Library in 3 different resolutions, 48×48, 72×72 and 300×300.

e.g.

<img src="https://handsonsharepoint-my.sharepoint.com/User%20Photos/Profile%20Pictures/joao_handsonsharepoint_onmicrosoft_com_LThumb.jpg
"/>

Graph

Microsoft Graph also provides the profile pictures but if you are building a solution to work inside SharePoint it doesn’t worth the effort to use it. You will need to setup the permissions to access the API and parse the stream result, one of the above methods will provide the same result much faster.

If you want to test this option, you can start with the Graph Explorer

Thanks to my friend David that helped me collecting these methods. 🙂

Designed by Freepik


No comments yet

Leave a Reply


Web developer focused on SharePoint branding, blogger, tech enthusiast. Travelling and sports are my addictions, knowledge and success are my daily motivations.