Goal : DAM asset path authored in a content fragment. content fragment selected to display on a page.
content fragment component need to render below html markup to utilize core component image (adaptive image servlet capabilities)
sample content fragment:
<img src="/content/experience-fragments/companysite/homepage/hero/master/_jcr_content/root/main-content/hero_copy.coreimg.jpeg/1679948264/homepage-hero.jpeg" class="cmp-image__image" itemprop="contentUrl" data-cmp-hook-image="image" alt="">
Does below solution work? Can someone suggest, how anyone achieved above ask.
Asset asset = resourceResolver.getResource(cfDamImageElementPath).adaptTo(Asset.class);
Image imageResource = new Image(asset);
image.setSelector(".img");
image.setAlt("asset metadata alt");
image.setLinkURL(asset.getPath());
return imgeResource.getHtmlTag(currentPage); //image tag
// use above result ${} in sightly htl
Thanks.
Sri