This week I was building a web part and needed to display the profile picture for a user. I figured this would be easy enough to do, but as is usually the case with Sharepoint, I was wrong. Several hours and multiple Google searches later, I put together a neat solution: UserProfileManager profileManager = new…
This week I was building a web part and needed to display the profile picture for a user. I figured this would be easy enough to do, but as is usually the case with Sharepoint, I was wrong. Several hours and multiple Google searches later, I put together a neat solution:
UserProfileManager profileManager = new UserProfileManager();UserProfile userProfile = profileManager.GetUserProfile(loginName);
try
{
pictureURL = userProfile[“PictureURL”].Value.ToString();
}
catch
{
pictureURL = “/layouts/images/nopic.gif”;
}