2

I have a list definition with Field of type User. I need to display a user's photo alongside with his name. In order to do that I'm using ShowField="NameWithPicture" attruibute like so:

<Field Name="Employee" ID="{33c2ee31-2927-4de3-8e7d-cc1f2676378b}" DisplayName="Name" Type="User" Required="TRUE" UserSelectionMode="PeopleOnly" UserSelectionScope="0" ShowField="NameWithPicture" />

Unfortunately in SharePoint 2013 there seems to a problem with the resulting markup:

enter image description here

enter image description here

Did anyone manage to do this task in SP 2013, please? Any help would be really appreciated!

1

This might be of some use.

Try to get the user profile using UserProfileManager. Then using GetProfileValueCollection(PropertyConstants.PictureUrl) you can get the image url of the user.

  • 1
    Thank you, Sane. So far I'm trying to use out-of-the box feature that allows me to show user profile picture without using C#. – Denis Molodtsov Oct 30 '13 at 9:13
1

Finally, we've managed to find a good solution. So, basically, in SharePoint 2013, instead of

<Field Name="Employee" ID="{33c2ee31-2927-4de3-8e7d-cc1f2676378b}" DisplayName="Name" Type="User" Required="TRUE" UserSelectionMode="PeopleOnly" UserSelectionScope="0" ShowField="NameWithPicture" />

you need to use

<Field Name="Employee" ID="{33c2ee31-2927-4de3-8e7d-cc1f2676378b}" DisplayName="Name" Type="User" Required="TRUE" UserSelectionMode="PeopleOnly" UserSelectionScope="0" ShowField="NameWithPictureAndDetails" />

Notice ShowField attribute

No C# development needed, and no JavaScript crutches.

I hope it helps someone!

Update

I've noticed that this problem occurs when you don't include JSLink node inside schema.xml in a View:

<JSLink>clienttemplates.js</JSLink>

This happenes when you upgrade Visual Studio Solution with SharePoint projects from 2010 to 2013 version.

schema.xml file for your list template

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.