StaticReferenceRewriteTransformerFactory not rewriting NamedImageTransformer urls | Community
Skip to main content
Level 2
August 16, 2023

StaticReferenceRewriteTransformerFactory not rewriting NamedImageTransformer urls

  • August 16, 2023
  • 1 reply
  • 889 views

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_01.png.transform/article.img.400/img.png>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

mahi1729
Level 4
August 16, 2023

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 

Level 2
August 16, 2023

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"
}