7/6/2017 - 4:25 PM

Rendering Custom Fields

@Html.Sitecore().Field("name of the field", anItemObject);

Add extra parameters through anonymous object
@Html.Sitecore().Field("myImageField", new { @class="imageright"} )

Available paraments:

EncloseTag(string) - Surrounds rendering results in another tag
Format(string)  - Formatting string for date and date time fields
@class(string) - Add a class attribute to <img> or <a> tags


Resizing Images on the server

@Html.Sitecore().Field(("my image field", new {mw=120, mh=120} )

mw- max width
mh- max heigh
w - width
h - height
as - allow stretch (allow changing aspect ratio)
bc - background color(when aspecct ration changes and does not fill entire area)


Rendering COmponent