Image not displaying when content fragment component is adapted to Image.class
Hi!
We are working with Content Fragments Models and Content Fragment Component (from core components 2.5) in AEM Sites 6.5 and 6.4. We have our models defined and as you know Content Fragment Component is not able to render images of the assets selected or set in the "Content Reference" data type, since this is a requiriment from our project, we are taking the path of the asset selected and adding a property "fileReference" to our content fragment component resource inside a page:

We have our sling model defined:
- @Model(
- adaptables = {SlingHttpServletRequest.class},
- resourceType = {ContentFragmentExt.RESOURCE_TYPE},
- defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL
- )
- public class ContentFragmentExt {
- private static final Logger log = LoggerFactory.getLogger(ContentFragmentExt.class);
- protected static final String RESOURCE_TYPE = "project/components/content/contentfragment";
- @Self
- private SlingHttpServletRequest request;
- @OSGiService
- private ModelFactory modelFactory;
- private Image image;
- @Inject
- private Resource resource;
- @PostConstruct
- private void init() {
- image = modelFactory.getModelFromWrappedRequest(request, resource, Image.class);
- }
- /**
- * @return the Image Sling Model of this resource, or null if the resource cannot create a valid Image Sling Model.
- */
- public Image getImage() {
- return image;
- }
In our image.html, we are using the resource of our proxy image component:
- <template data-sly-template.element="${@ element='the element value'}" data-sly-use.obj="${'project.sites.core.models.ContentFragmentExt'">
- <div data-sly-resource="${ obj.Image @ resourceType = 'project/components/content/image'}">
- </div>
- </template>
However, in the page, the asset is not loading:
We are using the ModelFactory in the component created as test from wknd tutorial and is working correctly with the same asset, is there a restriccion from the Image class to work with Content Fragment Component? The reason that we are going on this direction is because we need all the data displayed by the Image component of the asset for our analytics, and we can't use a simple <img src="image path from fragment">
Apologies for the long post, do you have any recommendation? is this possible?
Thank you !