How to Get Umbraco 8 User Avatar Url

Stephen Garside | Fri 06 Dec 19 > 1 min read

Creating an Umbraco 8 User Avatar and then including it as a blog image for an author can be achieved with just one line of code.

1. Crop a square image for use as your Avatar (square works best when resized).

2. In the Umbraco back office, select the user profile and upload the new profile picture:

change profile picture in umbraco 8 back office

3. Use the following line of MVC Razor code to get a handle on the Avatar image of the Blog article creator and output to screen.

<img class="avatar" src="/media/@Services.UserService.GetUserById(Model.CreatorId).Avatar.GetCropUrl()" />

And thats it! 3 steps and 1 line of code and you have the Avatar image from a user profile in Umbraco 8.

Leave Your Comments...