In SharePoint 2010 we made an effort to make our pages more inviting by using people’s profile pictures to identify them throughout the product. We also tried to fix stretching/scaling problems we had with the photos in O12, and wanted to provide administrators with an easier way to manage these photos by storing them in a central location.
The SharePoint 2010 profile picture story:
SharePoint 2010 maintains three differently sized thumbnails of the profile pictures to be used in different contexts in the product. Out of box, we use the large (144x144 px) thumbnail on the profile page contact card, the medium (96x96 px) thumbnail on the people search results page and the small (32x32 px) thumbnail on various webparts and controls displaying people data like the Newsfeed, Colleagues, In Common With You, Note Board and many others.
When a user uploads his profile picture using the photo upload UI on the “Edit Profile” page, we resize the uploaded image to create 3 thumbnails of above mentioned sizes. We do not crop the images but just resize them maintaining the original aspect ratio, so that the largest dimension matches the target thumbnail dimension. If the original image is smaller than the target size, we save the small image as the thumbnail instead of stretching it to meet the target. Here are some examples to make this clear:
All the photo thumbnails are stored in a folder named “Profile Pictures” under a Picture Library called “User Photos” under the MySiteHost site collection. Thus, we now have a centralized photo store holding the profile images for every user.
We have the following naming convention for the thumbnail files:
Image File Name
The full URL of the medium thumbnail (like, “ http://<mysitehost>/User Photos/Profile Pictures/<domain>_<username>_MThumb.jpg”) is stored in the user profile database.
SharePoint 2010 expects all the 3 thumbnails to be stored at the same location and follow the above file naming convention. Depending upon the context where the photo is rendered, SharePoint decides what thumbnail size to use and generates that URL from the _MThumb URL.
What does this mean for you?
As we’ve seen, there is some fairly substantial change in how the profile photos work in 2010. Let’s discuss how this affects you and how to make some common scenarios work:
Upgrading from 2007:
In 2007, we did not have the 3 differently sized thumbnails and the picture URLs in the 2007 profile database did not follow the new naming convention. If you simply use the data from the 2007 database, SharePoint UI will use the same picture URL in every context because we wouldn’t know how to pick the correct thumbnail size. This way we will possibly render a big image in an area meant for a smaller image and end-up with a broken page layout. So, we need to migrate the data from 2007 database to the new 2010-style format. We provide a powershell cmdlet to be run after upgrade to achieve this. From the SharePoint Management console, run:
Update-SPProfilePhotoStore -MySiteHostLocation http://<my site host URL>
This cmdlet would iterate over each user in the profile database, download their existing profile picture, create 3 correctly sized thumbnails from it and save them with proper names under the My Site Host “User Photos” picture library. On successful thumbnail creation, it will update the picture URL in the profile DB to the URL of the medium sized thumbnail.
The cmdlet updates the profile database, so it needs to be run from an account with the following permissions:
1. Connection permission to the User Profile Application on the Services farm. You can check this by going to Central Admin on the Services farm, navigating to the “Manage Service Applications” page, selecting the “User Profile Application” from the list, and then clicking the “Permissions” button in the UI. Only the accounts listed in there have permission to run UserProfile OM code.
2. “Manage Profiles” rights on the User Profile Application. Click on the “Administrators” button after selecting the “User Profile Application” and check the “Manage Profiles” check box.
Troubleshooting the cmdlet:
In case of any error in processing a given user’s picture (like the picture URL is invalid or unavailable), the cmdlet will skip the user and continue processing the remaining users. To capture a log of all errors and successes, you can turn on verbose and save the cmdlet output using Start-Transcript. Re-running the cmdlet will help fixing most cases, like, if a bunch of pictures were unavailable due to some network problem. The cmdlet skips picture URLs that follows the 2010 naming convention (that is, end in _MThumb), so re-running will only try to process the failed users.
Managing the photo store yourself:
Many of our customers want to create their own customized experience for photo upload and storage. If you are doing this, you should make sure to be compatible with the 2010 photo usage mechanism. This mainly boils down to following these rules:
1. Create three thumbnail image files of the standard sizes (larger dimension = 32, 96 and 144). There’s no standard SharePoint OM/web service to create image thumbnails - you have to use your own resize mechanism to create them, you can also ask the user to upload 3 different images if you choose to.
2. Name the image files following the SP 2010 naming convention (large ending in _LThumb, medium ending in _MThumb and small ending in _SThumb).
3. Store all the 3 thumbnail images at the same location (because SharePoint will try to generate URLs for the other two thumbnails from the medium thumbnail)
4. Use our OM to set the full URL of the medium (_MThumb) thumbnail as the PictureURL profile property for the user.
We hope this article will help you understand how SharePoint 2010 handles user’s profile photos and tune your existing photo upload and storage mechanism to work seamlessly with 2010. Please let us know any questions you have.
Written for SPSocial by,
Aditi Mandal, developer on SharePoint team.