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

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.

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

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.

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.

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


22 Responses to “How to get SharePoint profile picture”

  1. David Ramalho

    December 13, 2018

    Hi João 😀

    You can check the available sizes for Outlook on the link:
    https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/sizerequested

    Reply
  2. Anjani

    April 17, 2019

    Hi João,
    This is really a great article.

    In SharePoint Profile Picture,
    I have a requirement to pull user profile picture by UserName (eg: Anjani Challamcherla) instead of UserEmail (eg: Anjani.challamcherla@gmail.com). Do you think there is away to get that?

    Please help

    Reply
    • João Ferreira

      April 23, 2019

      Hi Anjani,

      Assuming that you are on SharePoint Online this email is from and external user.
      Is not possible to retrieve profile pictures from external users on SharePoint.

      Reply
  3. Luis Alejandro Soto

    May 19, 2019

    Great Article Brother!!!
    Thanks you very much!!!

    Reply
  4. Henrik M

    May 29, 2019

    Thanks for a great article.

    Reply
  5. Derek B

    June 28, 2019

    I am trying to use the Delve url in a SharePoint list to get the image for each employee based on email/id. The url works sometimes but other times throws a 401 error. It doesn’t consistently show the profile image. Any idea on this or have a suggestion for a workaround. It would be really nice to get the profile picture from delve, not the user photos.

    Thanks

    Reply
    • João Ferreira

      July 1, 2019

      Hi Derek,

      Unfortunately this is caused by a bad cookie, please follow the instructions below to get it fixed on your machine.

      1 – Copy the link to a profile picture that is not rendering
      2 – Paste it in the browser
      3 – Wait for the authentication window
      4 – After loading the image refresh the page with the web part

      If the issue persists after executing the steps above, please follow the steps described in these two articles from the Microsoft Tech Community.

      Bad cookies and the Office 365 Admin Center

      “400 Request Too Long” when navigating to profile

      Reply
  6. Jenn Martinelli

    July 30, 2019

    Hi, this was working fine for me a couple of weeks ago (the Delve option, I’m not tech staff so don’t have access to the server and backend options) but suddenly is not, no matter which user I select or other variables like size selection. I don’t get any kind of reply or response at all, just a completely blank page. Any idea why?

    Previously the link that worked for me was this option: https://nam.delve.office.com/mt/v3/people/profileimage?userId=%5Buserid%5D&size=L

    Reply
    • João Ferreira

      August 9, 2019

      Hi Jenn,

      There is a known issue with profile pictures on SharePoint that sometimes stop working.

      If you are experiencing this issue, please follow the instructions described below.

      Copy the link to a profile picture that is not rendering
      Paste it in the browser
      Wait for the authentication window
      After loading the image refresh the page with the web part
      If the issue persists after executing the steps above, please follow the steps described in these two articles from the Microsoft Tech Community.

      Bad cookies and the Office 365 Admin Center

      “400 Request Too Long” when navigating to profile

      Reply
  7. Mathew Bankuti

    August 16, 2019

    I have designed a list to pull profile information and try to pull the picture via the delve URL.

    The issue I have found is that the delve profile pictures will not load. Only if you visit delve first, THEN they all load on the page.

    Using other profile images work. The issue is that using the others if one doesn’t exist it displays an empty image, but with delve if the user has not uploaded an image to their profile they get a default people image. I would prefer to use the delve path, but cannot.

    Reply
    • João Ferreira

      August 16, 2019

      Hi Mathew,

      That’s a reality if the authentication token is not stored on the browser SharePoint will not be able to get the image from Delve?
      Can you give me a little bit more context of what are you trying to build so I can help you trying to find a solution?

      Looking forward to hear back from you.

      Reply
  8. Joe

    August 20, 2019

    Hi,
    Is there any way to check if the user has a profile image set, and if not, use the initials? I’m using the outlook api url to get users’ image and a lot of them don’t have their image set.

    Thanks in advance!

    Regards,
    Joe

    Reply
    • João Ferreira

      August 20, 2019

      Hi Joe,

      Out of the box is not possible, but I can help you building a workarround for it. Can you share with me the html structure and the javascript you are using to display the images.
      The tricky part will be getting the initials from the email. Are you using any character to separate the first and last name?

      Reply
  9. Gram

    July 28, 2020

    Are there any URL suffix that will pull the image with a round border (circular image)? I’m attempting some clever Nintex images to fetch the image based on Current User Email and concatenating that into the URL. It works great, but comes back as a square image and doesn’t quite match the aesthetic I’m going for. Thanks!

    Reply
    • João Ferreira

      July 28, 2020

      Hi Gram, no all the images are returned as sqaures. On the web you will be able no make it round with css, with Nintex I don’t know if the CSS will work.

      Have a nice day

      Reply
  10. Hugo Hernandez

    November 12, 2020

    Gram,
    Try using: borderRadius: 50%
    Regards,

    Reply
  11. Hugo Hernandez

    November 12, 2020

    Hi João Ferreira,
    Great document, thanks for sharing.

    Do you have a React JS snippet showing how to display the Graph Photo? or do you know if I can get that snippet by running Graph Explorer?

    I am getting the Photo binary but I haven’t been able to display it… : ( The reason I am trying this solution is because I am getting the intermittent photo display issues and the 401 Delve issue.

    Thanks in advance.

    Reply
  12. Pier

    January 22, 2021

    Is there any way to embed the content of an imgame through these links in an HTML tag in the email outlook? I am developing a stream in Microsoft Flow and when I use the image link it only works in Outlook Web.

    Reply
    • João Ferreira

      January 22, 2021

      Hi Pier, no unfortunately all this links require authentication. Have a nice day

      Reply
  13. Marco Friedmann

    February 10, 2021

    Hi Joao, how can I show a picture, using a person column? THis snippet unfortunately doesn’t work: {
    “$schema”: “https://developer.microsoft.com/json-schemas/sp/view-formatting.schema.json”,
    “hideColumnHeader”: true,
    “rowFormatter”: {
    “elmType”: “img”,
    “attributes”: {
    “src”: “/_vti_bin/DelveApi.ashx/people/profileimage?size=L&userId=[$Person.email]”
    }
    }

    }

    But it works when I substitute [$Person.email] with the email adress

    Reply

Leave a Reply to Anjani


I've been working with Microsoft Technologies over the last ten years, mainly focused on creating collaboration and productivity solutions that drive the adoption of Microsoft Modern Workplace.

%d bloggers like this: