/// <summary> /// Gets the URI of the Gravatar image for the specifications. /// </summary> /// <param name="urlHelper">The UrlHelper object getting the URI.</param> /// <param name="email">The email whose Gravatar source should be returned.</param> /// <param name="size">The size of the requested Gravatar.</param> /// <param name="defaultImage">The default image to return if no Gravatar is found for the specified <paramref name="email"/>.</param> /// <param name="maxRating">The maximum Gravatar rating to allow for requested images..</param> /// <returns>The URI of the Gravatar for the specifications.</returns> public static string Gravatar(this UrlHelper urlHelper, string email, int? size, string defaultImage, Rating? maxRating) { var gravatar = new Gravatar(); gravatar.DefaultImage = defaultImage; if (size.HasValue) gravatar.Size = size.Value; if (maxRating.HasValue) gravatar.MaxRating = maxRating.Value; return gravatar.GetImageSource(email); }
public static string GravatarUrl(this ApplicationUser user) { if (!string.IsNullOrEmpty(user?.Email)) { var gravatar = new Gravatar(); return(gravatar.GetImageSource(user.Email)); } else { return(noimage); } }
public static string GravatarUrl(this ViewContact contact) { if (!string.IsNullOrEmpty(contact?.Contact?.Email)) { var gravatar = new Gravatar(); return(gravatar.GetImageSource(contact.Contact.Email)); } else { return(noimage); } }
public static string GravatarUrl(this IIdentity identity) { var email = identity.Name; if (!string.IsNullOrEmpty(email)) { var gravatar = new Gravatar(); return(gravatar.GetImageSource(email)); } else { return(noimage); } }
/// <summary> /// Gets the URI of the Gravatar image for the specifications. /// </summary> /// <param name="urlHelper">The UrlHelper object getting the URI.</param> /// <param name="email">The email whose Gravatar source should be returned.</param> /// <param name="size">The size of the requested Gravatar.</param> /// <param name="defaultImage">The default image to return if no Gravatar is found for the specified <paramref name="email"/>.</param> /// <param name="maxRating">The maximum Gravatar rating to allow for requested images..</param> /// <returns>The URI of the Gravatar for the specifications.</returns> public static string Gravatar(this UrlHelper urlHelper, string email, int?size, string defaultImage, Rating?maxRating) { var gravatar = new Gravatar(); gravatar.DefaultImage = defaultImage; if (size.HasValue) { gravatar.Size = size.Value; } if (maxRating.HasValue) { gravatar.MaxRating = maxRating.Value; } return(gravatar.GetImageSource(email)); }