如何在AEM的Teaser组件中为图像添加Alt标签?

问题描述 投票:0回答:1

我想在预告片组件中添加类似于图片组件的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.52.6.04.1.0

aem sightly aem-6 teaser aem-core-wcm-components
1个回答
0
投票

在HTL Sling实现中,您可以在data-sly-resource上传递参数(使用请求属性-参见SLING-5812)。但是,这将要求图像的渲染了解这些并加以使用。

由于您似乎正在使用AEM WCM Core Components,因此图像组件将尝试从alt中获取alt property of the resource属性的数据。您可以包装资源并提供自定义alt属性来解决所需的内容。

© www.soinside.com 2019 - 2024. All rights reserved.