Open denisz1 opened 9 years ago
When styling emails, it is necessary to use inline styles in the style attribute, because webmail services (gmail and friends) strip out stylesheets.
style
The @Html.EmbedImage extension method can render the alt attribute, but not a style attribute. So I can't style my images.
@Html.EmbedImage
alt
The signature could be changed from:
public static IHtmlString EmbedImage(this HtmlHelper html, string imagePathOrUrl, string alt = "")
to:
public static IHtmlString EmbedImage(this HtmlHelper html, string imagePathOrUrl, string alt = "", string style= "")
And the final line from:
return new HtmlString(string.Format("<img src=\"cid:{0}\" alt=\"{1}\"/>", linkedResource.ContentId, html.AttributeEncode(alt)));
return new HtmlString(string.Format("<img src=\"cid:{0}\" alt=\"{1}\" style="{2}"/>", linkedResource.ContentId, html.AttributeEncode(alt), html.AttributeEncode(style)));
What do you think?
I've added a PR.
upvote
+1
Can someone tell me the syntax for the @HTML embed image tag with styles applied? For example, how would you add styles to this:
@Html.EmbedImage("~/Content/graphics/global/logo.png")
When styling emails, it is necessary to use inline styles in the
style
attribute, because webmail services (gmail and friends) strip out stylesheets.The
@Html.EmbedImage
extension method can render thealt
attribute, but not astyle
attribute. So I can't style my images.The signature could be changed from:
to:
And the final line from:
to:
What do you think?