Wednesday, February 10, 2016

How to retrieve user profile picture from user's My Site using SharePoint REST API

Social networking sites, personalization aesthetics and increased user interactions and expectations has changed the way website and portals are developed. 

One of the requirement often comes to SharePoint developers is to show user's profile picture on site/portal's home page or preferably in the site's header. SharePoint stores user related information in user's My Site but fetching the information from My Site and displaying it on other portal's pages could be a challenge. 

SharePoint REST API allows us to easily fetch all user profile related information and display it anywhere we want in the sharepoint portal. 

Below code snippet fetches the user's profile pic URL from user profile properties and assign it to a hyperlink tag on the page.

html to display profile pic as a background of a hyperlink.

Profile.js Javascript code to fetch profile pic url using Rest API and JQuery.

No comments:

Post a Comment