我怎样才能获得Sitecore的现场渲染器使用的CSS类的图像 [英] How can I get Sitecore Field Renderer to use a css class for an image
问题描述
使用Sitecore的(7)及MVC,我想知道如何为图像中添加Sitecore的CSS类属性字段渲染器。
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.
如果没有Sitecore的它看起来是这样的:
Without Sitecore it looks like this:
<div class="background-container">
<img src="/images/background-1.jpg" class="background">
</div>
使用Sitecore的:
With Sitecore:
<div class="background-container">
@Html.Sitecore().Field(Constants.Fields.HomeBackgroundImage)
</div>
似乎没有被添加类背景的图像本身Sitecore的一种方式。是否有另一种方式来做到这一点?
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?
感谢。
推荐答案
这就是我一直在寻找:
@Html.Sitecore().Field("MyFieldName", myItem, new { Parameters = new SafeDictionary<string> { { "enclosing-tag", "h2" } } })
<一个href=\"http://www.sitecore.net/Community/Technical-Blogs/SitecoreBetter/Posts/2013/06/Extending-the-Sitecore-renderField-pipeline.aspx\" rel=\"nofollow\">http://www.sitecore.net/Community/Technical-Blogs/SitecoreBetter/Posts/2013/06/Extending-the-Sitecore-renderField-pipeline.aspx
这篇关于我怎样才能获得Sitecore的现场渲染器使用的CSS类的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!