Skip to content

A simple ASP.NET MVC helper for Gravatar providing extension methods to HtmlHelper and UrlHelper.

License

Notifications You must be signed in to change notification settings

jkommer/GravatarHelper

Repository files navigation

GravatarHelper

Build status codecov license

NuGet Package Statistics
GravatarHelper GravatarHelper
GravatarHelper.Common GravatarHelper.Common
GravatarHelper.AspNetCore GravatarHelper.AspNetCore

A set of libraries providing Gravatar support to .NET and .NET Core .

Installation

To install GravatarHelper, run the following command in the Package Manager Console

ASP.NET MVC 3 / 4 / 5:

Install-Package GravatarHelper

ASP.NET Core MVC:

Install-Package GravatarHelper.AspNetCore

and add the following to your _ViewImports.cshtml file:

@using GravatarHelper.Common
@addTagHelper *, GravatarHelper.AspNetCore

Non-MVC:

Install-Package GravatarHelper.Common

Example Usages

GravatarHelper

Create a Gravatar img tag for "MyEmailAddress@example.com", 80 pixels large with "My Gravatar" as title and "Gravatar" as alt text.

@Html.Gravatar("MyEmailAddress@example.com", 80, new { Title = "My Gravatar", Alt = "Gravatar" })

Create a Gravatar link for "MyEmailAddress@example.com", 80 pixels large with "Identicon" as the default image.

<a href="@Url.Gravatar("MyEmailAddress@example.com", 80, GravatarHelper.DefaultImageIdenticon)">Your Gravatar</a>

Create a Gravatar Profile link for "MyEmailAddress@example.com".

<a href="@Url.GravatarProfile("MyEmailAddress@example.com")">Your Gravatar Profile</a>

GravatarHelper.AspNetCore

<img gravatar-email="MyEmailAddress@example.com" gravatar-size="80" alt="My Gravatar" />

Troubleshooting

GravatarHelper

The NuGet package should by default add two using statements to the /views/web.config file allowing Gravatar extension methods to be used throughout all view files. If this fails then you can manually add the following two namespaces to the /views/web.config file:

<system.web.webPages.razor>
  <pages>
    <namespaces>
      <add namespace="GravatarHelper.Common" />
      <add namespace="GravatarHelper.Extensions" />
    </namespaces>
  </pages>
</system.web.webPages.razor>

Or alternatively add the namespace directly to the relevant view files:

@using GravatarHelper.Common
@using GravatarHelper.Extensions

License

GravatarHelper is licensed under the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication