您需要使用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屬性截圖的問題。是的,我也使用「頁面」組件中存在的默認圖像對話框。請建議我可能出錯的地方。 –