在CQ5中添加自定义图像页面属性
问题描述:
CQ5中的每个页面都可以在页面属性中附加一个图像。我需要添加我自己的图像属性以用于组件。在CQ5中添加自定义图像页面属性
我可以使用this link添加小东西作为复选框,但是当我在页面属性中添加新图像选项卡时,即使现有图像也停止工作。 即使我可以在页面中添加另一个图像对话框,我也无法获取新图像。这是我添加的新图像对话框。 (见附件)
我只是想在转盘中使用的图像[也许用取,
Resource r = page.getContentResource("image1");
是否有人可以帮助我在此?我至少需要哪些属性才能使其工作?
答
您需要使用smartimage
的xtype
(或此版本,例如html5smartimage
)。
下面是一些示例代码,将在对话框中添加两个图像 - imageOne和imageTwo。您需要确保新映像的属性与现有映像的属性不冲突 - 即子节点resType
的子网节点fileNameParameter
,fileReferenceParameter
,name
和name
在下例中应该是唯一的。
<items jcr:primaryType="cq:TabPanel">
<items jcr:primaryType="cq:WidgetCollection">
<imageOnePanel
jcr:primaryType="cq:Panel"
title="Image One Panel">
<items jcr:primaryType="cq:WidgetCollection">
<imageOne
jcr:primaryType="cq:Widget"
border="true"
ddGroups="[media]"
fileNameParameter="./imageOne/fileName"
fileReferenceParameter="./imageOneFileReference"
height="300"
hideLabel="true"
name="./imageOne/file"
xtype="html5smartimage">
<items jcr:primaryType="cq:WidgetCollection">
<resType
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./imageOne/sling:resourceType"
value="foundation/components/image"
xtype="hidden"/>
</items>
</imageOne>
</items>
</imageOnePanel>
<imageTwoPanel
jcr:primaryType="cq:Panel"
title="Image Two Panel">
<items jcr:primaryType="cq:WidgetCollection">
<imageTwo
jcr:primaryType="cq:Widget"
border="true"
ddGroups="[media]"
fileNameParameter="./imageTwo/fileName"
fileReferenceParameter="./imageTwoFileReference"
height="300"
hideLabel="true"
name="./imageTwo/file"
xtype="html5smartimage">
<items jcr:primaryType="cq:WidgetCollection">
<resType
jcr:primaryType="cq:Widget"
ignoreData="{Boolean}true"
name="./imageTwo/sling:resourceType"
value="foundation/components/image"
xtype="hidden"/>
</items>
</imageTwo>
</items>
</imageTwoPanel>
</items>
</items>
从对话框&没有给予独特性能重用代码可能造成你的问题与添加第二个形象,虽然我不是你看到的错误100%。
非常感谢..我可以看到保存在CRX中的2张图片。但我的旋转木马中只需要其中的一个。我使用“资源r = page.getContentResource(”imageTwo“);”但我仍然得到默认图像,即如果我使用page.getContentResource(“image”); ..这一个的任何建议? –
嗯,我不确定 - 如果您按原样使用上述内容,或者您仍然在对话框中仍然有默认图像,那么在页面上应该没有任何内容称为“图像”?如果你打印'$ {properties.imageOneFileReference}'和'$ {properties.imageTwoFileReference}',你会得到预期的结果吗?如果没有看到您的JCR结构,很难确定发生了什么事情。 – anotherdave
感谢您的关注..我已经更新了与JCR属性截图的问题。是的,我也使用“页面”组件中存在的默认图像对话框。请建议我可能出错的地方。 –