Friday, 16 November 2012

Regarding contact field control and user profile picture

Hello Again,

Today new issue, new topic J.

Problem: In our project on page layout we have added the ContactFieldControl(Microsoft.SharePoint.Portal.WebControls) which shows the picture of user which specified as a contact, also shows users status and designation.
One of the user has deleted his profile picture then contact field control started showing the “red cross” for image of the user rather than OOB “Person (_layouts/images/person.gif)” image.  

Solution: Actually on page ContactFieldControl get the users image URL from hidden User Information List (/_catalogs/users/) and in this list, Picture field points out to URL of medium thumbnail image from User Photos library from MySite.

When user uploads his picture in his profile either through MySite or Central Admin, SharePoint creates three thumbnail images from the user picture and add those in User Photos library. Say for example user has uploaded his picture user.gif then SharePoint will create three different images (large thumbnail, medium thumbnail and small thumbnail) for user.gif in User Photos library on My Site.

When user first time log in to the site a record for the user is added into hidden User Information List and picture field of list is updated with medium thumbnail image url from User Photos from My Site.

But when user deletes his picture SharePoint removes the all three images from User Photos list but User Information List still points the same medium thumbnail image url and that’s why in ContactFieldControl it shows red cross rather than Person.gif.

So workaround to resolve this issue is set the Picture field value to null in User Information list using PowerShell script as follow:

#Get your root web
$web=Get-SPWeb "your web URL"

#Get the User Information list
$list= $web.SiteUserInfoList

#Get the respective user
$user=$web.Ensureuser("Your user display name")

#get the user from User Information List

#set the value of picture field to empty

#update the current list item

//update current list

I hope this will look interesting to you J Enjoy SharePoint J

As usual your Thoughts / Comments / Feedback are most welcome.

1 comment:

aparna john said...

Hi,The reason for this is quite simple, build a web page from scratch can be quite a daunting task, with a software program in Web Design Cochin that walks you through the process step by step you will be able to spend more time on how your page looks instead of trying to fix HTML code.Thanks.........