Skip to main content

Display user profile picture next to welcome name

Here is a simple way to add in the logged in users profile picture right before or after the users name in the SharePoint 2010 ribbon.

1.) Add the following to the top of your custom master page right before the doctype:
<%@ Register Tagprefix="SPSWC" Namespace="Microsoft.SharePoint.Portal.WebControls" Assembly="Microsoft.SharePoint.Portal, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>


2.) Add in the following control right before the welcome text:
<SPSWC:ProfilePropertyImage PropertyName="PictureUrl" style="float: left; height: 20px;" ShowPlaceholder="true" id="PictureUrlImage" runat="server"/>


A nice feature that you can customize is if you don’t want to show a placeholder image if a users has not uploaded a custom picture you can simply change ShowPlaceholder="true" to “false”. and it will only show a picture if someone has specified a custom one in their profile.



If you want to have the image on the right simply move the control after the welcome and muiselctor controls, also remove the float:left in the picture style:
<wssuc:Welcome id="IdWelcome" runat="server" EnableViewState="false"></wssuc:Welcome>

<wssuc:MUISelector ID="IdMuiSelector" runat="server"/>

<SPSWC:ProfilePropertyImage PropertyName="PictureUrl" style="height: 20px;" ShowPlaceholder="true" id="PictureUrlImage" runat="server"/>

The 20px height is that golden number because any larger and the image will get cropped off on the bottom in IE7 and in IE8 you will start to see some separation and cropping of the ribbon when viewing the other ribbon tabs.

30px height:

20px Height:

The inline CSS above on the control is just to keep this blog post simple, Its recommended to move that inline style into your custom CSS file.


rob said…

with this picture in place and the statusbar present i am trying to make the picture a link to the profile of the user currently logged in.

i managed to make the picture clickable and i can set the navigationUrl but i am looking for the link to the currentUser profile.

any thoughts?

with kind regards.
Naren said…

Thanks for the post. I was wondering if this picture could be used on site pages other than the master page?

I keep getting an error saying Unknown server tag 'SPSWC:ProfilePropertyImage' despite adding the server tag prefix in the code. Any suggestions?
dennis said…
@ Naren,

Are you by any chance trying this on foundation rather than SharePoint Server?
Mugsy said…
This has SAVED me! Any suggestions on how to do this on the My Site pages?
Sayed Majid said…
Thanks dear, I'm always getting User name and password each time I access the intranet the first time. is there any solution?
coldcertified said…
Rob - just use http:///person.aspx

Naren - Yes you can

Sayed - add your site to your trusted sites in IE OR switch to Kerberos
TSiggs said…
Noticed that when a user is viewing someone else's profile, instead of the currently logged in user the control displays the person's profile they are viewing. Looking for a workaround now...
vipin said…

How to make Picture clickable one ? any ideas ... kindly suggest.

Samo said…
hello, I've done this but unfortunately the displayed picture was the default one. i.e. the one which display if the user has no picture uploaded to his profile.

Any advice?
samo said…
Any replay, I'm using SP server 2010
Anonymous said…
Can this be done in Sharepoint Foundation as I seem to be getting the same problem as Naren?
Chakri said…
You can find SOLUTION here for foundation
Anonymous said…
Many Thanks Chakri.
Amin said…
well, no matter how many times i try it wont show it beside Current user,

i use Sharepoint server 2010,
before welcome after welcome ...

any suggestion?
Anonymous said…
Any idea how to make this work on My Sites? I am using feature stapling to staple my custom masterpage to the My Sites but I cant seem to get the image to appear next to the Welcome Menu...

The welcome menu is visible just the image is not and I have no idea what to do about it...Anyone have similar issues in My Sites?
Anonymous said…
I have three better ways to show the user image. You can find it on my blog:
Priyanka said…
Very nice info , it works in SharePoint 2013 as well just change the version to

Thanks for the article !!!
Dpnh said…
i am doing this on Office 365 site.
but issue is that image is getting fetched for first time. If i go to the 'My Profile' and return back then and only then image get displayed. How to solve this issue. I am getting User Information using JavaScript.
Unknown said…
Great guide. I am clearly gonna use it. And maybe reblog it.
Anonymous said…
This is there any way to make it work with WSS 3.0

Unknown said…

Where do I insert the picture for sharepoint users.

Is there a place in Active Directory or SharePoint where I can upload the pictures for all users.


Smita said…
This comment has been removed by the author.
Smita said…
Hi Eric,

I tried using the code in SPS 2013 but am getting following error:
Unknown server tag 'SPSWC:ProfilePropertyImage'

Following are the steps that I followed:
1. I edited "Seattle.html" page to add code in !--SPM: -- tag

When I checked the seattle.master page I saw that the first piece of code is not in the file.

Where am I going wrong?
Unknown said…
This comment has been removed by the author.
Unknown said…

I used this on my new productivity hub site and it throws up an error "<asp:Literal' is not a valid virtual path."

The path references java script for the hub site.

How can I get rid of this error?


Unknown said…
Hi,I wont reveal which ones I use in this article but I do have 3 different programs I use for Web Design Cochin. One I use to create pages from scratch, one I use to fix web pages that are messed up and the third one I use is one of the step by step software programs.Thanks....
How can we add this userprofile image in sharepoint2013 masterpage.I am also facing the same issue which smita reported.
Unknown said…

I have a slight problem with displaying the photo - when accessing mySite and view a different users profile the photo changes from the logged in user i.e. me to display the profile photo of the user who's profile I am viewing. Do you know how to get around this?

Thanks in advance

Popular posts from this blog

SharePoint 2010 Content Query for Blog Posts

I hope this post will help many of you feel comfortable with using the Content Query Web Part.In this post I will walk you through the process of creating a content query web part and configuring it to show custom field types. I will also give details on how to use XSLT to stylize and format the data being pulled. I will be using the following scenario as an example. Say that you had a site collection with a top level publishing site. This publishing site would display a the most recent blog posts from all blog sites within its own site collection. To solve this problem we will use a Content Query Web Part and a customized ItemStyle.xsl using XSLT.Please note that the “SharePoint Server Publishing Infrastructure” needs to be enabled at the site collection to display the content query web part.Step 1: Add a Content Query Web Part to PageNavigate to the site that you want the blog posts to show up and click on edit page. Under Editing Tools in the Ribbon, Click on insert > Web PartUn…

SharePoint 2010 Base CSS Classes

This will be the first of many SharePoint 2010 posts. I will be focusing on a few of the main CSS classes used for SharePoint 2010 Public Beta. As the product becomes more final there might be some changes to the class names but I will be sure to create a new post if that happens. This will be quite a lengthy but it should be helpful. The default CSS given below are just highlights of the full CSS attributes for that class.I will be using a basic team site as my base for the screenshots. Here is a basic structure of the main areas that I will cover.Ribbon RowTable Row Left Site Actions Navigate Up Edit Tab List Browse Page Table Row Right Give Feedback Welcome Menu WorkspaceBody Container Title Row Title Title Logo Title Text / BreadcrumbPage DescriptionSocial Data SeparatorI like It Tags/Notes Top Header 2/Top Links li Static-Selected li Static SearchHelpStatus Bar Container Main A…

How To: Hide Left Side Navigation on Home Page

I was recently asked: "How can I hide the side nav bar on the main homepage layout ?? I want to be able to use the side NAV with in the team site etc etc, but I don't want it on the front page.. " There are a couple of ways to do this in SharePoint 2010. If you are using a non-publishing site you can add a Content Editor Web Part to the page and add the following to the HTML Source.
body #s4-leftpanel
display: none;
margin-left: 0px;
Basically the CSS above hides the left navigation Div, and then sets the content area to not have a left margin. Once you are done, simply modify the web part and hide it on the page. If you are using a publishing site for your homepage simply add the same styles specified above to a custom page layout. That way if you have a need for other pages that do not need the left side navigation you can re-use the page layout.