4 Replies Latest reply on Jul 17, 2013 7:01 AM by todd_guerra

    Using Images in Newsletter

    todd_guerra Level 1

      My email newsletter is sending, but the images using the image component are sending as just the text of "file" instead of the image, and the images being pulled from my pages are sending as just alt text. Any pointers to actually get the images to send would be greatly appreciated. Thanks!

        • 1. Re: Using Images in Newsletter
          rush_pawan Level 4



          If your component on page is also not able to render the image then check you code and correct it. probably take a look at component "/libs/foundation/components/image"


          But if your component is rendering image and you have problem only with mails (in case you are using same approach to render the image) then try below.


          There may be one of issue


          1. The image tag <img> is using relative path for source file for example <img src="/content/dam/...."/> in that case it build the image path using default context from client system. So try to build full path like <img src="http://abcd.com/content/dam/...."/> and make sure the path http://abcd.com/content/dam/.... is public accessed. Usually it would use webserver or delivery network domain.


          2. May be you are building full URL for "src" attribute but that path is not accessible publically as mentioned above.


          I hope it helps you.




          • 2. Re: Using Images in Newsletter
            todd_guerra Level 1

            The image is publicly available, I have made sure to publish it out.


            I could understand this being an issue for the custom component I wrote that is simply drawing out the image...but why would this be a problem with CQ's OOTB newsletter image component? Wouldn't it take into account the fact that it's being sent out via email and then write the link to the image appropriately?

            • 3. Re: Using Images in Newsletter
              rush_pawan Level 4

              if you are using image API to display the image then offcourse it builds the image src link using relative path and in that case it will be not accessible through public area. so i mentioned you have to build full url link to make image available outside using public url. Let me know for more information.

              • 4. Re: Using Images in Newsletter
                todd_guerra Level 1

                I ended up just writing a service to pull the publish instance url, and then rewriting part of the link to match how it appears on the site. Pretty simple, but still an odd design flaw.


                Had the same issue with links, CQ transforms the links on send. Had to set a rule in the link checker to ignore links that start with the publish url. That seems very user un-friendly.


                Code example for building the image url:


                                String imagePath = objectContainingImage.getImage().getFileNodePath //or pull your image however you're pulling it

                                imagePath = StringUtils.replace(imagePath, "image/file", "image.img.jpg");

                                imagePath = StringUtils.replace(imagePath, "jcr:content", "_jcr_content");

                                imagePath = propertiesService.getPublishUrl() + imagePath;


                Something like that will make your image path work correctly, provided the properties service you set up has the right publish url (mine defaults to localhost:4503 for testing).