Externalizer not externalizing | Community
Skip to main content
Level 2
October 16, 2015
Solved

Externalizer not externalizing

  • October 16, 2015
  • 4 replies
  • 1552 views

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?

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

Have you read this blog written by one of our AEM developers:

http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2012/03/getting_to_know_theexternalizer.html

4 replies

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015
Sham_HC
Level 10
October 16, 2015

The implementation looks right & strange behaviour. Can you delete /var/classes/org/apache/jsp/*  and browser cache & then verify.  

Level 2
October 16, 2015

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.

Level 2
October 16, 2015

smacdonald2008 wrote...

Have you read this blog written by one of our AEM developers:

http://experiencedelivers.adobe.com/cemblog/en/experiencedelivers/2012/03/getting_to_know_theexternalizer.html

 

 

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!