aem - 如何在 AEM 的 Teaser 组件中为图像添加 Alt 标签?
问题描述
我想在预告片组件中添加类似于图像组件的 alt 标签。
OOTB 预告片组件使用数据狡猾的资源。
<sly data-sly-template.image="${@ teaser}">
<div data-sly-test="${teaser.imageResource}" data-sly-resource="${teaser.imageResource}"></div>
</sly>
我可以在 data-sly-resource 上传递属性值吗?
<div data-sly-test="${teaser.imageResource}" data-sly-resource="${teaser.imageResource @ alt = properties.alt}"></div>
提前致谢。
AEM 6.5 2.6.0 4.1.0
解决方案
在 HTL Sling 实现中,您可以传递参数data-sly-resource
(使用请求属性 - 请参阅SLING-5812)。但是,这将要求图像的渲染了解这些并使用它们。
由于您似乎正在使用AEM WCM 核心组件,图像组件将尝试alt
从alt
资源的属性中获取属性数据。您可以包装资源并提供自定义alt
属性来满足您的需求。
推荐阅读
- python - 如何编写程序以使用 Pyhton 中的字符串格式打印最多 2 位小数的浮点数
- c++ - 如何在c++中生成一个不等于n和m的1到k之间的随机数?
- python - 遍历帐号列中的每一行并使用这些行来读取其他 Excel 文件
- firebase - 在flutter中获取firebase中的所有注册用户
- c# - ISO 8601 字符串到 C# 日期时间:丢失时区
- javascript - 未处理的拒绝 (ReferenceError):未定义 createPromise
- ios - iOS: How to add Assets folder inside a Framework and how to access them in code?
- php - 出现错误 505,无法运行我的网站
- linux - 使用终端将文件从ubuntu复制到Windows服务器?
- python - 如何在 Python 中将 Web 服务调用的大型 json 响应转换为 CSV?