2013-07-11 59 views
1

CQ5中的每個頁面都可以在頁面屬性中附加一個圖像。我需要添加我自己的圖像屬性以用於組件。在CQ5中添加自定義圖像頁面屬性

我可以使用this link添加小東西作爲複選框,但是當我在頁面屬性中添加新圖像選項卡時,即使現有圖像也停止工作。 即使我可以在頁面中添加另一個圖像對話框,我也無法獲取新圖像。這是我添加的新圖像對話框。 (見附件)

我只是想在轉盤中使用的圖像[也許用取,

Resource r = page.getContentResource("image1"); 

JCR-structure-of-image-dialog

是否有人可以幫助我在此?我至少需要哪些屬性才能使其工作?

回答

3

您需要使用smartimagextype(或此版本,例如html5smartimage)。

下面是一些示例代碼,將在對話框中添加兩個圖像 - imageOneimageTwo。您需要確保新映像的屬性與現有映像的屬性不衝突 - 即子節點resType的子網節點fileNameParameterfileReferenceParameternamename在下例中應該是唯一的。

<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%。

+0

非常感謝..我可以看到保存在CRX中的2張圖片。但我的旋轉木馬中只需要其中的一個。我使用「資源r = page.getContentResource(」imageTwo「);」但我仍然得到默認圖像,即如果我使用page.getContentResource(「image」); ..這一個的任何建議? –

+0

嗯,我不確定 - 如果您按原樣使用上述內容,或者您​​仍然在對話框中仍然有默認圖像,那麼在頁面上應該沒有任何內容稱爲「圖像」?如果你打印'$ {properties.imageOneFileReference}'和'$ {properties.imageTwoFileReference}',你會得到預期的結果嗎?如果沒有看到您的JCR結構,很難確定發生了什麼事情。 – anotherdave

+0

感謝您的關注..我已經更新了與JCR屬性截圖的問題。是的,我也使用「頁面」組件中存在的默認圖像對話框。請建議我可能出錯的地方。 –