gpt4 book ai didi

css - 如何让 Sitecore Field Renderer 为图像使用 css 类

转载 作者:行者123 更新时间:2023-11-28 11:10:21 26 4
gpt4 key购买 nike

使用 Sitecore (7) 和 MVC,我想知道如何将图像的 css 类属性添加到 sitecore 中的字段渲染器。

没有 Sitecore 它看起来像这样:

<div class="background-container">
<img src="/images/background-1.jpg" class="background">
</div>

使用 Sitecore:

<div class="background-container">
@Html.Sitecore().Field(Constants.Fields.HomeBackgroundImage)
</div>

在 Sitecore 中似乎没有办法将类背景添加到图像本身。还有其他方法吗?

谢谢。

最佳答案

这就是我要找的:

@Html.Sitecore().Field("MyFieldName", myItem, new { Parameters = new SafeDictionary<string> { { "enclosing-tag", "h2" } } })

参见 Extending the Sitecore RenderField pipeline .

关于css - 如何让 Sitecore Field Renderer 为图像使用 css 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22233831/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com