Is it possible to create Sling Rewrites for DAM asset paths? For instance, I'd like to rewrite the path to all images in my html.
By default the html looks like this:
<img src="/content/dam/products/shirt.jpg" />
But, I'd like to rewrite the path so it looks like this:
<img src="/assets/products/shirt.jpg" />
I've added the following rule to the Resource Resolver Factory:
And included this as a Rewrite Element in the Link Checker Transformer:
But the rewrite doesn't get applied at all. I've tried editing the configurations in both via the Felix console and the repository. But, no luck. Does Sling apply to the DAM? Or is there another preferred way to achieve the same result?
Solved! Go to Solution.
Can you set the loglevel of the class com.day.cq.rewriter.linkchecker.impl.LinkCheckerTransformer to DEBUG and post the results?
Hi Jörg, I've attached the log file. I can see that links to html pages are being rewritten, but not links to DAM assets. (<img> paths aren't being rewritten either). According to the article smacdonald2008 posted above, "the CQ runtime system by default only uses the mapping rules for URLs associated with HTML pages. So links to things like PDFs stored in the DAM never get rewritten."
This seems to align with the behavior I'm seeing. Do you agree / disagree?
By any chance is there an out-of-the-box feature available in AEM 6 that would handle this? (We are currently on 5.6.1).