Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Sling Mappings for DAM Assets

Avatar

Level 3

Hi All,

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: 

/content/dam(.*)</asset$1

 

And included this as a Rewrite Element in the Link Checker Transformer: 

img:src

 

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?

1 Accepted Solution

Avatar

Correct answer by
Level 10
4 Replies

Avatar

Employee Advisor

Hi,

Can you set the loglevel of the class com.day.cq.rewriter.linkchecker.impl.LinkCheckerTransformer to DEBUG and post the results?

kind regards,
Jörg

Avatar

Level 3

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).

Avatar

Correct answer by
Level 10

According to this sling doc:

http://sling.apache.org/documentation/bundles/output-rewriting-pipelines-org-apache-sling-rewriter.h... 

Its output that is changed - not static DAM assets.