We've created some html email templates in CQ5. We've got a web service that grabs the appropriate one and hands the raw html off to another service that actually sends the thing. The html has static assets in the DAM presented via a cq.adaptiveimage component.
Of course, this doesn't work for us. All of the assets are referenced by relative URL, which is great if the page is being served by AEM, but not so great for an email template.
I've attempted to implement a new component called "External Adaptive Image". I've just copied the adaptiveimage component from libs/foundation/components, and altered the jsp like this:
<%@include file="/libs/foundation/global.jsp"%><% %><%@page session="false" import="com.day.cq.commons.Externalizer, // Redacted Adobe-supplied includes org.apache.sling.api.resource.ResourceResolver"%><% %><% // This is Adobe-supplied, but it's just to give you an idea where I // inserted my code String fileReference = properties.get("fileReference", ""); if (fileReference.length() != 0 || resource.getChild("file") != null) { // Redacted Adobe-supplied code // My new things ResourceResolver rr = slingRequest.getResourceResolver(); Externalizer exernalizer = rr.adaptTo(Externalizer.class); %>
After this, I just use the externalizer's absoluteLink method to augment the existing data-src divs:
<div data-src='<%= exernalizer.absoluteLink(slingRequest, "http", path + ".img.320.low." + extension + suffix) %>' data-media="(min-width: 1px)"></div>
This just results in more relative URLs though. They look like this:
<div data-src="/content/a/b/c/d/en/welcome/jcr:content/par/adaptiveimage_extern.img.320.low.png/1401316368975.png" data-media="(min-width: 1px)"></div>
I'm expecting something more like:
<div data-src="http://my.thing.com/content/a/b/c/d/en/welcome/jcr:content/par/adaptiveimage_extern.img.320.low.png/1401316368975.png" data-media="(min-width: 1px)"></div>
Anyone have experience using the Externalizer? Am I doing something wrong?
Solved! Go to Solution.
Have you read this blog written by one of our AEM developers:
Have you read this blog written by one of our AEM developers:
The implementation looks right & strange behaviour. Can you delete /var/classes/org/apache/jsp/* and browser cache & then verify.
Sham HC wrote...
The implementation looks right & strange behaviour. Can you delete /var/classes/org/apache/jsp/* and browser cache & then verify.
Thanks! I tried that, and the behavior continues :( I'll open a support ticket, and respond back to this forum if we get a solution.
smacdonald2008 wrote...
Have you read this blog written by one of our AEM developers:
Thanks for the response!
I sure did! Also the javadocs for Externalizer and ResourceResolver. I posted what I was doing, above - doesn't work. Any idea why? Are you saying I'm not obtaining my Externalizer the right way?
Thanks again!