public static HtmlString GravatarImage(this HtmlHelper htmlHelper, string emailAddress, GravatarOptions options = null) { if (options == null) { options = GravatarOptions.GetDefaults(); } var imgTag = new TagBuilder("img"); emailAddress = string.IsNullOrEmpty(emailAddress) ? string.Empty : emailAddress.Trim().ToLower(); // <-- adding support for CSS if (!string.IsNullOrEmpty(options.CssClass)) { imgTag.AddCssClass(options.CssClass); } // adding support for CSS --> imgTag.Attributes.Add("src", string.Format("http://www.gravatar.com/avatar/{0}?s={1}{2}{3}", GetMd5Hash(emailAddress), options.Size, "&d=" + options.DefaultImageType, "&r=" + options.RatingLevel ) ); return(new HtmlString(imgTag.ToString(TagRenderMode.SelfClosing))); }
public static HtmlString GravatarImage(this HtmlHelper htmlHelper, string emailAddress, GravatarOptions options = null) { if (options == null) options = GravatarOptions.GetDefaults(); var imgTag = new TagBuilder("img"); emailAddress = string.IsNullOrEmpty(emailAddress) ? string.Empty : emailAddress.Trim().ToLower(); // <-- adding support for CSS if (!string.IsNullOrEmpty(options.CssClass)) { imgTag.AddCssClass(options.CssClass); } // adding support for CSS --> imgTag.Attributes.Add("src", string.Format("http://www.gravatar.com/avatar/{0}?s={1}{2}{3}", GetMd5Hash(emailAddress), options.Size, "&d=" + options.DefaultImageType, "&r=" + options.RatingLevel ) ); return new HtmlString(imgTag.ToString(TagRenderMode.SelfClosing)); }