ImageParser

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:

RequestResponse

<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"
   LowResSrc="sitecore\Admin_pa00bdlb\en\218a6965-c8ab-46bd-91f9-f647459354a0\da2c68c9-5bce-417d-b2a7-5e75e951ebf0.jpg"
   HighResSrc="sitecore\Admin_pa00bdlb\en\218a6965-c8ab-46bd-91f9-f647459354a0\da2c68c9-5bce-417d-b2a7-5e75e951ebf0.jpg"
   HorizontalScale="" VerticalScale=""
   Skew="0" ObjectStyle="[Normal Graphics
   Frame]" WMode="0" WOffset="0;0;0;0;0;"
   WInvert="0" WSide="0" WCont=""
   SitecoreID="{A0540709-8F91-49AE-826E-E99F5F80BDB7}"
   RequestSender="1"
   SitecoreMediaID="{DA2C68C9-5BCE-417D-B2A7-5E75E951EBF0}"
/>
</Inline>  

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,