Kentico CMS 6.0 Developer's Guide

Displaying avatars in transformations

Displaying avatars in transformations

Previous topic Next topic Mail us feedback on this topic!  

Displaying avatars in transformations

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

User avatars

 
User avatars can also be displayed in transformations by using the <%# GetUserAvatarImage( ... ) %> method. Here are some examples of how it can be used:

 

The following method returns the image tag of the avatar contained in the AvatarGuid field of the currently transformed user, with a maximum sidesize of 50 px. and Alt tag equal to the user's Nickname or Username. The AvatarGuid field must be accessible for this method to work:

 

<%# GetUserAvatarImage(50, HTMLEncode(GetNotEmpty("UserNickname;UserName"))) %>

 

The following method returns an image tag displaying the current avatar of the user with ID UserID, with a maximum sidesize of 200 px. and an Alt tag equal to the user's Username:

 

<%# GetUserAvatarImage(Eval("UserID"), 200, 0, 0, Eval("UserName")) %>

 

The following method returns the image tag of the avatar with ID UserAvatarID, of user with ID UserID, with a maximum sidesize of 50 px. and Alt tag equal to the user's Username:

 

<%# GetUserAvatarImage(Eval("UserAvatarID"), Eval("UserID"), 50, Eval("UserName")) %>

 

The following method returns the image tag of the avatar with ID UserAvatarID, of user with ID UserID, with a maximum width of 40 px., maximum height of 45 px. and Alt tag equal to the user's Username:

 

<%# GetUserAvatarImage(Eval("UserAvatarID"), Eval("UserID"), 0, 40, 45, Eval("UserName")) %>

 
Group avatars
 
Group avatars can by displayed using the <%# GetGroupAvatarImage( ... ) %> method. Here are some examples:

 

The following method returns the image tag of the group avatar contained in the AvatarGuid field of the currently transformed group, with a maximum sidesize of 50 px. and Alt tag equal to the group's Display name. The AvatarGuid field must be accessible for this method to work:

 

<%# GetGroupAvatarImage(50, Eval("GroupDisplayName", true)) %>

 

The following method returns the image tag of the group avatar with ID GroupAvatarID, with a maximum sidesize of 50 px. and Alt tag equal to the group's Display name:

 

<%# GetGroupAvatarImage(Eval("GroupAvatarID"), 50, Eval("GroupDisplayName", true)) %>

 

The following method returns the image tag of the group avatar with ID GroupAvatarID, with a maximum width of 40 px., maximum height of 45 px. and Alt tag equal to the group's Display name:

 

<%# GetGroupAvatarImage(Eval("GroupAvatarID"), 0, 40, 45, Eval("GroupDisplayName", true)) %>

 

Image tag

 

The following is an example of an image tag generated by the <%# GetUserAvatarImage( ... ) %> method. As you can see, the method uses the ~/CMSModules/Avatars/CMSPages/GetAvatar.aspx page to get the source image.

 

<img style="border-width: 0px;" alt="Andy" src="/CMSModules/Avatars/CMSPages/GetAvatar.aspx?avatarguid=42f9d97e-b0c8-43a2-8a35-62dfec5ae64a&amp;maxsidesize=50" />