xtype = html5smartimage sightly

时间:2018-03-22 06:50:42

标签: java dialog aem sightly

我在我的对话框中使用了html5smartimage。下面是我在dialog.xml中添加的代码。

<image
jcr:primaryType="cq:Widget"
xtype="html5smartimage"
name="./imgFile"
fieldLabel="Image"
style="border: 2px dashed #ccc;"
height="200"
ddGroups="[media]"
fieldDescription="To use a customized icon please upload it to the dam and add it here."
allowUpload="{Boolean}false"
requestSuffix=".img.png"
renditionSuffix="/_jcr_content/renditions/original"
cropParameter="./imageCrop"
fileNameParameter="./fileName"
fileReferenceParameter="./fileReference"
rotateParameter="./imageRotate" />

我在我的组件中添加了这些代码行,但我仍然得到了#34;没有数据&#34;。我可以拖放图像,但阅读它似乎是唯一的问题

<sly data-sty-test.imgFileObj="${properties.imgFile}"></sly>

<div data-sly-test="${!imgFileObj}">
theres no data
</div>
<div data-sly-test="${imgFileObj}">
theres is data
</div>

我到处检查但无济于事。所以对此有任何帮助将不胜感激。最终目标是获取图像网址。

1 个答案:

答案 0 :(得分:0)

html5smartimage 不会通过“name”属性保存数据。它支持许多设置,因此根据图像的配置方式,您可以期望以不同的方式保存数据。

如果将图像拖放到窗口小部件中,则会使用与“fileReferenceParameter”关联的属性名称保存图像。在您的情况下,它将是data-sty-test.imgFileObj="${properties.fileReference}

如果上传了图片,则会创建一个子节点,其名称在 fileNameParameter 中提供。