eladnava/mailgen

adding and styling product images

Jelmerovereem opened this issue · 1 comments

I'm trying to add product images to the receipt.
I've tried to add a <img> inside the item property.

data: [
  {
    item: `<img src="${product.image}" style="max-height: 50px;">${product.name}`
  }
];

And the image shows in the email, but the size is different in each email client, probably because not every client recognises the max-height. So is there any correct way to implement product images into the emails?

ps: I love the work you did on this package! Very handy and easy to use.

Hi @Jelmerovereem,
Glad to hear you're liking mailgen :)

I'd recommend using the width or height attribute directly on the <img> tag:

<img src="${product.image}" height="50">${product.name}

This is supported in all major e-mail clients, but it does slightly complicate your implementation, as you need to know the exact image height in advance.

Please give it a try, and let me know if you have any further questions.