private static void PrepareAttribute(IDomObject domElement, AttributeToCss attributeToCss) { string name = attributeToCss.AttributeName; string value = attributeToCss.CssValue; //When rendering images, we need to prevent breaking the WIDTH and HEIGHT attributes. See PreMailerTests.MoveCssInline_HasStyle_DoesNotBreakImageWidthAttribute(). //The old code could end up writing an image tag like <img width="206px"> which violates the HTML spec. It should render <img width="206">. if (domElement.NodeName == @"IMG" && (name == "width" || name == "height") && value.EndsWith("px")) { value = value.Replace("px", string.Empty); } domElement.SetAttribute(name, value); }
private static void PrepareAttribute(IElement domElement, AttributeToCss attributeToCss) { string name = attributeToCss.AttributeName; string value = attributeToCss.CssValue; //When rendering images, we need to prevent breaking the WIDTH and HEIGHT attributes. See PreMailerTests.MoveCssInline_HasStyle_DoesNotBreakImageWidthAttribute(). //The old code could end up writing an image tag like <img width="206px"> which violates the HTML spec. It should render <img width="206">. if (domElement.NodeName == @"IMG" && (name == "width" || name == "height") && value.EndsWith("px")) { value = value.Replace("px", string.Empty); } domElement.SetAttribute(name, value); }