Using Sitecore (7) & MVC, I'd like to know how to add a css class attribute for an image to the field renderer in sitecore.
Without Sitecore it looks like this:
<div class="background-container">
<img src="/images/background-1.jpg" class="background">
</div>
With Sitecore:
<div class="background-container">
@Html.Sitecore().Field(Constants.Fields.HomeBackgroundImage)
</div>
There doesn't seem to be a way to add the class background to the image itself in Sitecore. Is there another way to do this?
Thanks.
Benutzer
This was what I was looking for:
@Html.Sitecore().Field("MyFieldName", myItem, new { Parameters = new SafeDictionary<string> { { "enclosing-tag", "h2" } } })
来源:https://stackoverflow.com/questions/22233831/how-can-i-get-sitecore-field-renderer-to-use-a-css-class-for-an-image