The ImageParser creates an Inline element and inserts an image node inside. The width and height attributes are necessary for both the Image and the Inline object.

For example:

An image link in Sitecore usually looks like this:

<img alt="" height="300" width="300" src="~/media/DA2C68C95BCE417DB2A75E75E951EBF0.ashx?h=300&amp;w=300" />

When you insert an image link in rich text, you can enter alt, width, and height attributes. By default, the width and height of the image item are automatically inserted.

If you clear the alt, width, and height values, the link becomes:

<img alt="" src="~/media/DA2C68C95BCE417DB2A75E75E951EBF0.ashx" />

The dimensions of an img node can be set using the "style" attribute, or the "width" and "height" attributes. When parsing image dimensions, if both "style" and "width"/"height" attributes are present, "style" attribute values takes precedence over "width"/"height" attribute values. If none is present, then the dimensions of the sitecore media item are used.Result:


<Inline Type="Graphic" Height="79.374999999" Width="79.374999999"Position="AboveLine" Alignment="Left">
<Image X="0" Y="0" Width="79.374999999" Height="79.374999999" Rotation="0" Name="__Standard Values"
   HorizontalScale="" VerticalScale=""
   Skew="0" ObjectStyle="[Normal Graphics
   Frame]" WMode="0" WOffset="0;0;0;0;0;"
   WInvert="0" WSide="0" WCont=""

The inline element attributes are hardcoded, the image element is rendered as default (from the __Standard Values item of the P_Image), and the image paths, dimensions, and ObjectStyle are set.

Do you have some feedback for us?

If you have suggestions for improving this article,