Displaying User Profile Picture

Ilya Buzytsky asked on May 14, 2016 17:26

Hi, I need to display a user image defined in Users application in Settings -> User picture field. In several different places (Repeater, Static Image, Static HTML, via transformation, as menu item image, etc.) I apply values of a macro associated with the current user. All macros I tried so far (as I can see in Macro Debugger) bring null. Where is my problem, and how to show user image on site? Some of the macros I tried to use are:

{% CurrentUser.UserPicture #%} {% CurrentUser.UserSettings.FirstItem.UserPicture #%} {% CurrentUser.UserSettings.FirstItem.UserAvatar #%} {% MembershipContext.AuthenticatedUser.UserPicture #%} {% MembershipContext.CurrentUserProfile.UserSettings.FirstItem.UserAvatar #%} transformation method GetUserAvatarImage

Thanks

Recent Answers


Roman Hutnyk answered on May 14, 2016 20:23

For ASPX transformation in repeater you could use transformation method:

<%# GetUserAvatarImage(200, "Alternate text") %>

Find more options here.

Also there are web parts like User Public Profile and Users Viewer that could help you to output user related data, including avatar.

0 votesVote for this answer Mark as a Correct answer

Ilya Buzytsky answered on May 14, 2016 22:30 (last edited on May 14, 2016 22:31)

Thanks, Roman. I see correct image in Users->Settings and in My Profile applications. But when I use Transformation method <%# GetUserAvatarImage(200, "Alternate text") %> I get 404 error on GetAvatar.aspx file, while the path where it was looked for seems weird: http://

0 votesVote for this answer Mark as a Correct answer

Ilya Buzytsky answered on May 14, 2016 22:33

Thanks, Roman. I see correct image in Users->Settings and in My Profile applications. But when I use Transformation method <%# GetUserAvatarImage(200, "Alternate text") %> I get 404 error on GetAvatar.aspx file, while the path where it was looked for seems weird: ~/CMSPages/GetAvatar.aspx. According to Kentico 9 documentation (you sent me link to), method GetUserAvatarImage( ... ) uses GetAvatar.aspx in another path: ~/CMSModules/Avatars/CMSPages/GetAvatar.aspx. I don't find file GetAvatar.aspx anywhere in my installation. How can I get installed? Thanks, Evgeny

0 votesVote for this answer Mark as a Correct answer

Roman Hutnyk answered on May 15, 2016 04:00

Have you tried other methods from documentation, where you explicitly specify user id?

0 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on May 15, 2016 09:55

Hi Evgeny,

I can attest your findings. I didn't see that file even in my installation of both kentico 8.2 & 9. However I searched for this file fo you on kentico git hub. Here is the link for the file. You may download it from here. You can download both .aspx and .aspx.cs file from below

https://github.com/KuduApps/Kentico/tree/master/CMSModules/Avatars/CMSPages

Thanks, Chetan

1 votesVote for this answer Mark as a Correct answer

Ilya Buzytsky answered on May 15, 2016 22:58

No luck so far. Roman, I tried also other GetUserAvatarImage calls with same results. Chetan, I added to my WebSite solution files GetAvatar.* I downloaded from GitHub, but build is failing on missing base class GetFilePage (public partial class CMSModules_Avatars_CMSPages_GetAvatar : GetFilePage). It seems one of two happened: either GetUserAvatarImage is obsolete, in which case there should be some other working solution to achieve same goals, or at least two above classes are missing from installation by mistake. If the latter is the case, can you help to prioritize a hot-fix to add them. And still unclear to me why neither one of macro properties keeps user avatar picture? It would be also nice to get fixed. Thanks!

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.