API Questions on Kentico API.
Version 6.x > API > APIs to obtain GetMemberProfileUrl and Avatagr Image in cs files View modes: 
User avatar
Member
Member
kirannshetty-gmail - 2/7/2013 11:45:53 PM
   
APIs to obtain GetMemberProfileUrl and Avatagr Image in cs files
Hi All,
I need a function to obtain MemberProfileUrl based on a username and avatarimage based on userid in ascx.cs files.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 2/20/2013 7:10:12 PM
   
RE:APIs to obtain GetMemberProfileUrl and Avatagr Image in cs files
Hi,

The MemberProfileUrl can be obtained in transformations using method
GetMemberProfileUrl(object memberNameObj, string siteName)

or directly using ModuleCommands construction:
URLHelper.ResolveUrl(CMSContext.GetUrl(ModuleCommands.CommunityGetMemberProfilePath(memberName, siteName)))


The AvatarImage can be obtained in the transformation method
public string GetUserAvatarImageForUser(object userID, int maxSideSize, int width, int height, object alt)

which returns avatar image tag and if avatar is not defined returns gender depend avatar or user default avatar if is defined.

If you would specify where exactly do you want to obtain those URLs, we could find the most suitable method.

Regards,
Zdenek

User avatar
Member
Member
vasiliy.ivanov1975-gmail - 11/19/2013 12:41:53 AM
   
RE:APIs to obtain GetMemberProfileUrl and Avatagr Image in cs files
Hello,
I need some method for Kentico 6 to get default avatar, if specified user does not have one. GetUserAvatarImageForUser seems to work good, but I don't use transformation in my particular case. And AvatarInfoProvider.GetAvatarInfo returns just null for user who don't have avatar.

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/19/2013 4:24:16 AM
   
RE:APIs to obtain GetMemberProfileUrl and Avatagr Image in cs files
Hi,

Thank you for your message.

In your code you can check if the avatar info is null or not. If it is null you can return some other image instead. Wouldnt this approach work?

Kind regards,
Richard Sustek

User avatar
Member
Member
vasiliy.ivanov1975-gmail - 11/19/2013 4:37:43 AM
   
RE:APIs to obtain GetMemberProfileUrl and Avatagr Image in cs files
Hi Richard,
I do this way now, i just was curious if there's something more robust to use. But you're right, your method works.

Best regards,
Vasiliy

User avatar
Kentico Consulting
Kentico Consulting
Kentico_RichardS - 11/19/2013 4:44:21 AM
   
RE:APIs to obtain GetMemberProfileUrl and Avatagr Image in cs files
Hi,

I dont think there is somehing better then this approach. You are simply requesting an avatar info and if the info is not there you want to do some custom action - get some custom image. You can see that this would not be wanted in many of the cases as sometimes you dont want to get the default image.

You could also define some your own method which would return Avatar image if there is one or default image if there is not.

Kind regards,
Richard Sustek