Skip to content
Phillip Haydon edited this page Aug 2, 2013 · 1 revision

Snow supports adding Gravatar Images, if you're using the Default or Per-Post email properties, you can invoke the extension method: EmailToGravatar()

Generating the Image Uri

If your Default settings has the following property:

"email": "phillip@example.com"

You can use in your views:

@Model.Email.EmailToGravatar()

This will generate a image uri like:

http://www.gravatar.com/avatar/608955cd42dcd78ed8b548c2012d6ff2.jpg?

The method has an override to pass in the size, should you want to define an image as 200x200 pixels, you can pass in 200 as the parameter.

@Model.Email.EmailToGravatar(200)

Will result in

http://www.gravatar.com/avatar/608955cd42dcd78ed8b548c2012d6ff2.jpg?s=200

Razor Helper for an HTML IMG tag

You can also use the Razor Helper to create an image tag for you.

By calling:

@Html.RenderGravatarImage(Model.Email)

You will get:

<img src="http://www.gravatar.com/avatar/608955cd42dcd78ed8b548c2012d6ff2.jpg?" />