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:
![Screenshot 2023-05-05 072516.png Screenshot 2023-05-05 072516.png](https://experienceleaguecommunities.adobe.com/t5/image/serverpage/image-id/57333i112C57257B86A43F/image-size/large?v=v2&px=999)
<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