Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Externalizing links not working for assets

Avatar

Level 2

Hi,

 

We have have implemented externalizer which works fine for all the links. However src property of images are not externalized. We do not conditionally externalize links.

 

For pages or image components that render within AEM it isn't much of a problem. However this becomes an issue with content fragments. The main reason we create a content fragment is to expose it to outside apps.

 

We have a content fragment which is exposed via the assets api to the react app. If we add and image into the Rich text editor, that image is not externalized making it totally useless to react app. 

 

Any thoughts on how this can be resolved?

4 Replies

Avatar

Community Advisor

Hey guruprasadb9915, Have you tried creating a link transformer for this requirement? just target the <img> tag and update the <src> attribute and it will transform the src the way you want. Thanks!

Avatar

Level 2

Hi bilala23933647,

Yes I have the link transformer configured. But I still do not see it transforming the img src even for html pages. Only the anchor tags are handled by Externalizer. Link transformer seems to be doing nothing.

 

link trans.JPG

 

However when I request the content fragment from Assets API, neither the anchor link nor the img src is externalised or re-written. This seems to be a fundametal requirement when we expect the content fragment to be consumed by other apps.

 

Also I am not a fan of using a JSON exporter (i mean mode.json). It just feels redundant to create a page for content fragment. I know I will run into caching issues (cant invalidate the cached content) if I dont create a page. What is the purpose of this asset API? It does not seem to help in any way.

Avatar

Community Advisor

Hi @guruprasadb9915 , I don't understand why your default transformer is not coming to picture but if it still continues to do so, you can write a new custom LinkTransformer.

if (attributes.getIndex("src") == -1) {
attributes.addAttribute(StringUtils.EMPTY, "src", "src", "xs:string", "customSrc");
}

This will make sure that src is targeted while rendering the html.

Avatar

Level 2
It will not solve the problem as link transformer or externalizer is not triggered when the request is made from assets api. I am not looking for a solution for HTML pages