Share via


SharePoint 2010, Office 2010 and Profile Pictures

As many of you will know SharePoint & Office make heavy use of your profile pictures to personalize the experience.  For example, here is my profile photo in my My Site.

image

I get to set up this stuff up quite often in demo environments & so i thought i would post about the process for doing this.

The first thing is to get the photos into your My Site.  Easiest way to do that is to manually upload it via your profile page.  But you can also use some code to upload the file (use UploadSPFile powershell commandlet) to a document library and then use some more powershell to set the “PictureUrl” profile property property to point at the uploaded file.

Example Uploading Photo:

[Microsoft.SharePoint.SPFile]$file = UploadSPFile -url ([string][string]"https://intranet/my/") -libraryName "User Photos" -filePath "<path to photo to upload here>"

*** UPDATE *** Get Supporting PS File with UploadSPFile function from here.

Example Setting Profile Property:

$upm = GetProfileManager -url $siteUrl
$up = $upm.GetUserProfile("CONTOSO\danj");

$picturePropertyName = GetProfilePropertyName -UserProfileManager $upm -PropertyName "PictureUrl";

if (-not [System.String]::IsNullOrEmpty($picturePropertyName))
{
$PortraitUrl = CombineUrls -baseUrl $file.Web.Url -relUrl $file.ServerRelativeUrl;
$up.get_Item($picturePropertyName).Value = $PortraitUrl;
}

This will simply set the picture you uploaded as the profile picture.

But wait … there’s more …

You can upload a picture of any dimensions and size … however SharePoint and Office have some images sizes that work best in the UI and SharePoint provides some help to get all your pictures resized to 3 sizes it needs. 96x96 is the largest optimal profile picture size.

SharePoint provides a powershell command to automatically resize all your profile pictures for you.

Example, resizing profile pictures to optimal resolutions:

Update-SPProfilePhotoStore –MySiteHostLocation “https://intranet/my/”

This command will take a look at every users profile picture and will do two things:

  1. Re-Size the photo into the 3 optimal sizes and save them in SharePoint
  2. Set the users profile property to the newly resized photo

Now you should have great looking photos in SharePoint.  Additional tip for getting great photos … make sure you start with a square image.  That way you make use of the optimal viewing window for profile pics in SharePoint.

Now … that is the SharePoint part out of the way.  The next part is getting photos into apps like Outlook and Communicator.

The Exchange blog has a great post on this topic and so i won’t repeat here.  You can read that post here: GAL Photos in Exchange 2010 and Outlook 2010

Here is some additional reading on this topic:

The best part about setting all this up is that people will quickly realize they don’t have a photo set up in SharePoint and will not want to be left out!  Sooner or later you will get nice rich looking SharePoint profiles & pictures for people in Outlook.

-CJ

Comments

  • Anonymous
    May 11, 2010
    The comment has been removed

  • Anonymous
    June 17, 2010
    Hi Chris, You mention to use UploadSPFile powershell commandlet, where can I find this? Similar issue with GetProfileManager and GetProfilePropertyName

  • Anonymous
    June 28, 2010
    The comment has been removed

  • Anonymous
    July 21, 2010
    Hi,  I was wondering if you could publish the PowerShell scripts you used to update the PictureURL in the User Profile Service. Many thanks Giles

  • Anonymous
    August 02, 2010
    Chris:  Where can I download this UploadSPFile powershell cmdlet you reference above for uploading photos?  I am running SP2010 and do not see it as an available cmdlet.

  • Anonymous
    August 03, 2010
    Hi Everyone, Please see the update in the blog post for the reference file with the UploadSPFile function referenced.   Sorry for the confusion. Thanks, -Chris.

  • Anonymous
    August 18, 2010
    Hello, Thank you Chris, for your post.  I was able to upload a picture and set the user profile correctly, but I would like to be able to upload photos to the "Profile Pictures" folder within the "User Photos" picture library.  Would you or anyone else know how to change the SPUtils.ps1 file to allow for that? Also, I have not seen where the Update-SPProfilePhotoStore -MySiteHostLocation "http://sp2010/my" command is actually doing anything.  Any recommendations there? Thanks Ben

  • Anonymous
    August 19, 2010
    Hi Ben, The SPProfilePhotoStore should be creating the 3 correctly sized versions of your profile images and storing them in the MySite Host image library.  Take a look there for them. Thanks, Chris.

  • Anonymous
    August 19, 2010
    Chris Right now my script is uploading the picture to "http://sp2010/my/User Photos", but the location actually used by manually uploading a photo is "http://sp2010/my/User Photos/Profile Pictures".  “Profile Pictures” is a folder within the “User Photos” picture library.  I would prefer to use the “Profile Pictures” directory so that if a user decides to update their photo manually, through the “Edit My Profile” page, it will delete the old photo.  Do you happen to know how the SPUtils could be modified to support uploading to a folder within a picture library? Also I checked the Update-SPProfilePhotoStore -MySiteHostLocation "http://sp2010/my" command again, and I'm still not having any luck with it creating the three thumbnails.  I have also successfully implemented a photo resizing method that will create the three thumbnails the exact same dimensions as SharePoint’s built-in resizing.  These can be uploaded and are referenced correctly by SharePoint as well. Thanks Ben