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.

StaticReferenceRewriteTransformerFactory not rewriting NamedImageTransformer urls

Avatar

Level 2

I have static reference rewriter configured to write all static assets like images, css, js to a static domain like https://static.mydomain.com. However, it doesn't rewrite the image src urls for images that use the acs commons NamedImageTransformerImpl. However, it works properly for all assets which don't have the ".transform" in the url (used by the NamedImageTransformerImpl).  An example is below where it doesn't perform the rewrite.

 

<img src="/content/dam/abc/tenants/cbs/insights/image/D7_insight-banner_1440x810px_01.png.transform/article.img.400/img.png">

 

So, it leaves these image links alone. Any idea how to get it to rewrite to <img src="https://static.mydomain.com//content/dam/abc/tenants/cbs/insights/image/D7_insight-banner_1440x810px...>

2 Replies

Avatar

Level 5

May be its worth sharing your rewriter configuration. Usually order or priority matters and in the rewriter config all other config also needs referencing. Just to make sure have an anchor tag and an img tag with same asset path and debug to see if it fails only with img tag. We can figure out from that where the issue probably is. Thanks 

Avatar

Level 2

This is mysite.xml in 'config.rewriter' folder

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:Folder"
contentTypes="[text/html]"
enabled="{Boolean}true"
generatorType="htmlparser"
order="{Long}1"
serializerType="htmlwriter"
transformerTypes="[linkchecker,mysite-static-refs]">
<generator-htmlparser
jcr:primaryType="nt:unstructured"
includeTags="[A,IMG,SCRIPT,LINK,SOURCE]"/>
</jcr:root>


this is the StaticReferenceRewriterTransformerFactory.cfg.json

{
"host.pattern":[
"$[env:static_domain]"
],
"attributes":[
"img:src",
"source:srcset",
"link:href",
"script:src"
],
"matchingPatterns":"[img:srcset;(\/content\/.+?[jpg|png|jpeg|svg]) .+?w]",
"host.scheme":"https",
"prefixes":[
"/etc.clientlibs",
"/etc",
"/libs",
"/content"
],
"pipeline.type":"mysite-static-refs"
}