How do you add a second image to a proxied core image component? | Community
Skip to main content
Art_Bird
Level 2
February 24, 2023
Solved

How do you add a second image to a proxied core image component?

  • February 24, 2023
  • 1 reply
  • 676 views

AEM 6.5.12 & Core components 2.17.14

I need to create an image component that proxies the core component . It needs a primary and secondary image. The dialog is just two fileupload nodes. I can do it with just one image but I can't figure out how to add a second.


My first thought was to set fileNameParameter, fileReferenceParameter, & name to something like this to make it easier for the sling model to find them.

 

<primaryFile fileNameParameter="./primary/fileName" fileReferenceParameter="./primary/fileReference" name="./primary/file"> <secondaryFile fileNameParameter="./secondary/fileName" fileReferenceParameter="./secondary/fileReference" name="./secondary/file">

 

Problem is I can't figure out how to point my sling model to the files. I tried this in my sling model but it didn't work.

 

@Self @Via(type = ResourceSuperType.class) @ValueMapValue(name="primary") Image primaryImage; @Self @Via(type = ResourceSuperType.class) @ValueMapValue(name="secondary"). Image secondaryImage;

 

What am I missing to make this work?

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 kaikubad

You will not be able to this on this way because core component only works if its an image component or inherited from image component. The possible thing you can do is

1. Create new component from image component

2. Customize dialog, make a way to add multiple files.

3. Use model class to make a list of image resource with your primary image and secondary image.

4. Then on htl create a loop with your image list resource.

 

Reading your requirement this idea came to mind. This is the basic idea, when you actually implement this some things might needs to be changed.

1 reply

kaikubad
Community Advisor
kaikubadCommunity AdvisorAccepted solution
Community Advisor
April 26, 2023

You will not be able to this on this way because core component only works if its an image component or inherited from image component. The possible thing you can do is

1. Create new component from image component

2. Customize dialog, make a way to add multiple files.

3. Use model class to make a list of image resource with your primary image and secondary image.

4. Then on htl create a loop with your image list resource.

 

Reading your requirement this idea came to mind. This is the basic idea, when you actually implement this some things might needs to be changed.