1

I'm working on an SPFx web part which displays the company's employees from a list. One of the primary functions of the web part is to pull a couple of Users' current profile pictures from Delve.

This works fine if I have visited Delve recently, but if I haven't, the page doesn't load the picture. This appears to be because of a need for an active connection with Delve when the page loads. Is there a way to ping Delve before the web part renders the HTML to ensure that End Users will see the Profile Pictures?

Edit

The Code which references the image is:

let pPic = "background-image: url(https://nam.delve.office.com/mt/v3/people/profileimage?userId=PLACEHOLDER&size=L)";

and this is inserted to the HTML using:

<td rowspan="2" class="${styles.prof}" style="${pPic}">

Also, the PLACEHOLDER referenced in pPic is replaced with the User's email address between these two snips.

  • Can you post the code snippet that you are using to pull data ? I might have an idea. – Gautam Sheth Apr 11 '18 at 15:03
  • I've added the code as requested. – vanblart Apr 11 '18 at 15:10
2

You are facing this issue because the page on which your webpart is present would be something like https://tenant.sharepoint.com/sites/test/SitePages/abc.aspx, whereas the image you are using is from https://nam.delve.office.com. This means that they are different domains which causes the browser to restrict cross-data interaction.

So, to get around this issue, you need to use the userphoto.aspx URL. It is a proxy page used by Microsoft themselves to get around this issue.

Modify your code as below:

let pPic = `background-image: url(${this.context.pageContext.site.absoluteUrl}/_layouts/15/
userphoto.aspx?size=L&accountname=${encodeURIComponent(<Email>)}`;

Make the necessary changes as per your variable names and user's email address.

  • One of the user's photos isn't loading properly. Is this link pulling from Delve's profile picture? – vanblart Apr 11 '18 at 15:55
  • 1
    is it accessible in browser ? The profile photos are stored in User Profile Service, which is where we are pulling data from. What's the issue with this user ? – Gautam Sheth Apr 11 '18 at 16:02
  • A placeholder image is downloaded when I manually navigate to the url. – vanblart Apr 11 '18 at 16:08
  • 1
    It usually means that the user has not uploaded delve image. If the user has uploaded an image, it will take some time to get populated in the User profile, usually from couple of hours to 2-3 days. Has the user uploaded image in delve ? – Gautam Sheth Apr 11 '18 at 16:10
  • They do have an image in Delve, however while I am currently looking at their page I'm noticing that on the Left Hand Navigation, their image is the placeholder and on their profile there is an image? – vanblart Apr 11 '18 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.