Developing component with two ’html5smartimage’ widgets | Community
Skip to main content
Level 4
October 16, 2015
Solved

Developing component with two ’html5smartimage’ widgets

  • October 16, 2015
  • 2 replies
  • 1249 views

Hi experts!

I would like to develop a component that renders some text and two images. I’m getting as a reference the ‘foundation/components/image’ component to render the images, using the ‘com.day.cq.wcm.foundation.Image’ class (see at [1]), like:

… Image image = new Image(resource); … <% image.draw(out); %> …

I can render my component with one image, and it works fine. But I don’t know how to add the second one.

For the first image, I’ve added, in the compoment dialog, a ‘cq:Widget’ of xtype=’html5smartimage’ (as the ‘foundation/components/image’). For the second image, I should add a second html5smartimage widget, but the properties of both widgets will collide.

I’ve tried to change the values of properties of the image (./imageCrop, ./filename, ./fileReference, etc.), adding a prefix (./imagenPrincipal/imageCrop, ./ imagenPrincipal/filename, ./ imagenPrincipal/fileReference, etc.). But then the image is not rendered, because the ./imagenPrincipal node in /content/… doesn’t contains the sling:resourceType node (that refers to the component, that inherits from ‘foundation/components/parbase’, that is the component that really renders the image, with the ‘img.GET.java’ class.

So, how can I include two html5smartimage widgets in my component and use them to render both images with ‘com.day.cq.wcm.foundation.Image’ class?

Thank you very much!!

[1] http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/wcm/foundation/Image.html

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by PaulMcMahon

Take a look at how the the dialog is configured in /libs/foundation/components/textimage. If provides a proper example of how to configure the image on a sub-node. Notice the key issues is adding sling:resourceType hidden property on the sub-node. This allows all the normal image related functionality to work. In the example it points to foundation/components/image, however if you have written any custom image scripts that are stored either in your own image component, of if you have a project specific parbase component you may want to use that instead. 

2 replies

PaulMcMahonAccepted solution
Level 8
October 16, 2015

Take a look at how the the dialog is configured in /libs/foundation/components/textimage. If provides a proper example of how to configure the image on a sub-node. Notice the key issues is adding sling:resourceType hidden property on the sub-node. This allows all the normal image related functionality to work. In the example it points to foundation/components/image, however if you have written any custom image scripts that are stored either in your own image component, of if you have a project specific parbase component you may want to use that instead. 

Level 4
October 16, 2015

Perfect answer. Absolutely clear! wink

Thank you orotas!