Problem
In our project on page layout we have added the ContactFieldControl (in Microsoft.SharePoint.Portal.WebControls) that shows the picture of the user that is specified as a contact, also shows the user's status and designation.
If one of the users have deleted his profile picture then the contact field control begins showing the “red cross” for the image of the user rather than the OOB “Person (_layouts/images/person.gif)” image.
Solution
Actually the page ContactFieldControl gets the user's image URL from the hidden User Information List (/_catalogs/users/) and in this list, the picture field points to the URL of the medium thumbnail image from the User Photos library from MySite.
When the user uploads his picture in his profile, either using MySite or Central Admin, SharePoint creates three thumbnail images from the user picture and adds those to the User Photos library. Say for example the 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 the User Photos library on My Site.
When the user logs into the site the first time a record for the user is added into the hidden User Information List and the picture field of the list is updated with the medium thumbnail image URL from the User Photos from My Site.
But when the user deletes his picture SharePoint removes all three of the images from User Photos list but the User Information List still points to the same medium thumbnail image URL and that's why in ContactFieldControl it shows a red cross rather than a Person.gif.
So the workaround to resolve this issue is to set the Picture field value to null in the User Information list using a PowerShell script as follows:
- 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.
- $listitem=$list.GetItemById($user.Id)
- Set the value of picture field to empty.
- Update the current list item.
- Update current list.
I hope this will look interesting to you.
Enjoy SharePoint.
As usual your thoughts, comments and feedback are most welcome.