Freigeben über


Photo Management in SharePoint 2010

 

Introduction:

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:

Original

Large

Medium

Small

200x100

144x72

96x48

32x16

40x40

40x40

40x40

32x32

 

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:

Thumbnail

Image File Name

Size

Large

domain_username_LThumb.jpg

144x144

Medium

domain_username_MThumb.jpg

96x96

Small

domain_username_SThumb.jpg

32x32

 

The full URL of the medium thumbnail (like, “ https://<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 https://<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.

Comments

  • Anonymous
    January 06, 2011
    Thanks for this update. I do have another question: about bulk uploading images (and adding the correct metadata): Is there any documentation on how to add metadata to more than one picture at the time? We have 1.000nds of pictures and it would be very nice if we can add metadata in one go. Any suggestions for this issue?

  • Anonymous
    January 11, 2011
    Hi, thanks for this thorough explanation, it's really helpful! I'm trying to upload my user's profile images programatically using Peter Holpar's code : pholpar.wordpress.com/.../how-to-upload-a-user-profile-photo-programmatically and got it working in a test environment. It won't however work in the production environment - completely new install etc of SharePoint Server 2010. I have all permissions, and I get the red cross with text 'User Photo'. If I right click on 'Properties' of this non-image, it has the correct pictureURL. I've been stuck on this problem for ages and any help would be GREATLY appreciated. In my code the URL values are correct, as well as the image paths, etc...all seem fine. Thank you!!

  • Anonymous
    January 19, 2011
    Theres an app for that spc3.codeplex.com/wikipage

  • Anonymous
    February 03, 2011
    What I can see you don't maintain aspect ratio resizing profile photo. At least in forums where small thumbnail is used. My original 146x220 sized photo becomes 32x32 and I look a little flat. Probably there is some feature to turn on?

  • Anonymous
    February 15, 2011
    I have a question regarding image file extension. Does thumbnail feature in SP2010 supports other image types?  For example, PNG, BMP or GIF.

  • Anonymous
    February 17, 2011
    Thanks , very useful information regarding user profile images. -Aravind aravindrises.blogspot.com

  • Anonymous
    April 18, 2011
    Is it possible to customize the size of those thumbnails? For ex. a company set the profile container to 189x189, therefore they want large thumbnails to be that size. Is that posible? How? Thanks!

  • Anonymous
    May 12, 2011
    Chris I get the same error have you found a fix? I have all permissions, and I get the red cross with text 'User Photo'. If I right click on 'Properties' of this non-image, it has the correct pictureURL.

  • Anonymous
    May 22, 2011
    Thanks , very useful information regarding user profile images. I want to ask you one question. please give me any suggestion. I want to put validation when users upload profile image. some users upload portrate image and some users upload landscape image. so, i want users to upload only one (landscape image or portrate image) and want to make validation for that. any suggestion... it is possible? Thanks

  • Anonymous
    September 07, 2011
    Question: How do i manage the profile picture library when it exceed 5000 item?

  • Anonymous
    September 07, 2011
    My question:  I get that 3 thumbnail sizes are provided however, is there a way of limiting the size (mb) of the thumbnail chosen.  Does the thumbnail size affect the rest of the environment & document uploads etc...? Cheers

  • Anonymous
    December 03, 2011
    Here is a nice tool that allows user to change both SharePoint profile picture and Active Directory user picture: www.harepoint.com/.../Default.aspx Thanks.

  • Anonymous
    October 21, 2013
    Is there any way to save whole users pics to  default storage to upload in new environment? thanks in advance

  • Anonymous
    April 28, 2015
    Nice Post Thanks, I have an question that If i have created the users named as "test.user" and "test_user" . Below PictureURL created for the above users      http://mysite.com/User Photos/Profile Pictures/test_user_MThumb.jpg i.e "." is converted into "_". Due to this the same picture shown for two users. Please advice me.

  • Anonymous
    October 28, 2015
    Hi AGR, I have run into the exact same problem. Have you found a work around to the issue ?