Image in e-mail

  • Posts: 583
  • Thank you received: 22
  • Hikaserial Subscription Hikashop Multisite
5 years 8 months ago #295438

-- HikaShop version -- : 3.5.0
-- Joomla version -- : 3.8.10
-- PHP version -- : 7

Hi,

I have removed the image from the table into all the e-mails but the image is still to see as an attachment in the e-mail.
Which code should I adjust to prevent this?

See screenshots:







So I think I have to edit something in the Preload version. But I do not know which code I need to change since I am not a developer.

Could you please give me a hint.
I think this Preload code need to be adjusted because it's the only code about images.

Hope you can help me.

Kind regards,
Lumiga
$cartProduct = array(
			'PRODUCT_CODE' => $item->order_product_code,
			'PRODUCT_QUANTITY' => $item->order_product_quantity,
			'PRODUCT_IMG' => '',
		);

		if(!empty($item->images[0]->file_path) && $config->get('thumbnail', 1) != 0) {
			$img = $imageHelper->getThumbnail($item->images[0]->file_path, array(50, 50), array('forcesize' => true, 'scale' => 'outside'));
			if($img->success) {
				if(substr($img->url, 0, 3) == '../')
					$image = str_replace('../', HIKASHOP_LIVE, $img->url);
				else
					$image = substr(HIKASHOP_LIVE, 0, strpos(HIKASHOP_LIVE, '/', 9)) . $img->url;
				$attributes = '';
				if($img->external)
					$attributes = ' width="'.$img->req_width.'" height="'.$img->req_height.'"';
				$cartProduct['PRODUCT_IMG'] = '<img src="'.$image.'" alt="" style="float:left;margin-top:3px;margin-bottom:3px;margin-right:6px;"'.$attributes.'/>';
			}
		}


Kind regards,
Lumiga
Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 81378
  • Thank you received: 13037
  • MODERATOR
5 years 8 months ago #295452

Hi,

The images are embedded in the emails only if you have the "Embed images" setting activated in the HikaShop configuration.
The way it works is that the email sending process in class.mail will scan the HTML of the email, and when it finds an img tag, it will take the image URL and load its content in the email.

So the issue is that the img tag is still in the HTML of the email. Instead of <!-- and --> to add HTML comments around the img tag (which cannot be detected by the email sending process) you should completely remove the tag {LINEVAR:PRODUCT_IMG}.
That way, you would get the img tag in the HTML of the email at all and thus the image wouldn't be embedded.
An alternative is simply to turn off the "Embed images" setting.
Finally, you could also keep it like you have it and change the line:

$cartProduct['PRODUCT_IMG'] = '<img src="'.$image.'" alt="" style="float:left;margin-top:3px;margin-bottom:3px;margin-right:6px;"'.$attributes.'/>';
to:
$cartProduct['PRODUCT_IMG'] = '';
in the preload to actually not add the img tag even if you have the {LINEVAR:PRODUCT_IMG} tag in the HTML version.

The following user(s) said Thank You: Lumiga

Please Log in or Create an account to join the conversation.

Time to create page: 0.074 seconds
Powered by Kunena Forum