Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Replace Content ID (cid) images in email notifications

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 07-09-2018, 06:24 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 70
 

Default Replace Content ID (cid) images in email notifications

CID or Content ID images are used across all email notifications. What would it take to change that to using standard linked images, at least for the main logo? Well...

1) First find the template that is used for notifications: skins/mail/common/common/layout.twig

But this doesn't contain the logo image. Instead, the template calls {{ this.getNotificationHeader()|raw }}

2) Let's head to that function. Is it returning the image? Another template? Nope. This returns a translation string: for example "emailNotificationCustomerHeader" (or the admin one).

3) Easy! So you can simply modify that translation string and change the way the image is embedded. Nope! That translation string contains a big block of HTML but the logo itself isn't there. Instead, there's a placeholder in the form of %logo%. Uhhh! Well, let's see where that is replaced...

4) Let's head to XLite/Core/Mailer.php where we can find the getVariableValueLogo() function which returns the following:

Code:
return sprintf( '<a href="%s"><img src="%s" alt="%s" style="max-width:100%%;" width="100%%" /></a>', $shopURL, $logo, $companyName );

Right. So, that $logo variable must contain the logo source in the form of "cid:your_logo_file.jpg@mail.lc" which is what I want to replace. Nope! That actually contains what I want, in other words, the full path to the logo image.

5) I then found XLite/Model/MailImageParser and the substImage() function which calls the getImgSubstitution() function which returns:

Code:
return 'cid:' . $this->images[$img]['name'] . '@mail.lc';


That will replace any (all) image contained in the email notification. So that's where you need to change something if you don't want to use CID images.

Hope that this might help someone else who would need to do that change as well.

Seriously, I spent about 3 hours trying to figure out where that was. I wonder how this could possibly get more complicated. You have an entire process of replacing stuff in every email notification, so why doesn't your product have a simple option to turn this on and off? A simple admin setting such as "Use CID images: Yes/No".

You can't even modify ANY email notification template to just include a linked image with <img src="path/to/image.jpg"> because it WILL be replaced by a CID image as part of the parsing process. Damn!

Oh... and a friendly note to X-Cart dev team: In HTML language, the <img> tag has no end tag.
__________________
5.3.5.8
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:50 PM.

   

 
X-Cart forums © 2001-2020