Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

height: 'auto' in defaultAttributes for 'mj-image' breaks template draft #2578

Closed
olgaplaga opened this issue Nov 17, 2022 · 5 comments
Closed

Comments

@olgaplaga
Copy link

By default, there are defined defaultAttributes for mj-image tag that include:

static defaultAttributes = {
    align: 'center',
    border: '0',
    height: 'auto',
    padding: '10px 25px',
    target: '_blank',
    'font-size': '13px',
  }

Adding heigt="auto" by default breaks image display inside email drafts in the Apple Mail application. Images are not displayed at all or are not correctly scaled.

Possible solutions for this issue:

  1. Don't add height="auto" by default to images (if it is not really necessary)
  2. Allow skipping height="auto" by MJML (before compilation) without the need to define image height to a particular size.
  3. Compile height to the tag style= without adding it as a separate height attribute.
@iRyusa
Copy link
Member

iRyusa commented Nov 17, 2022

Adding heigt="auto" by default breaks image display inside email drafts in the Apple Mail application.

I'm not sure what's the usecase here as sending HTML email via clients will alter the HTML and most likely break the email.

However you can add height="" to mj-image and reset it with mj-attributes if you want so. I'm not sure if the blank height attribute will do something bad tho.

@olgaplaga
Copy link
Author

Thanks for the quick answer @iRyusa .

I'm not sure what's the use case here as sending HTML emails via clients will alter the HTML and most likely break the email.

I know that sad phenomenon, however, I believe that the more such use cases can be captured and corrected from a code perspective, the scope for uncontrolled HTML changes between email clients can decrease. This particular case I reported is an important part of a project I'm working on, and I believe many developers will find the option to have more control over it helpful.

I have tested the blank height attribute and it still causes the same problem as with height="auto" .

@iRyusa
Copy link
Member

iRyusa commented Nov 17, 2022

As fair as I remember the height auto isn't mandatory but it helps some version of Outlook to keep the aspect ratio in some cases.

I'll check if I can do a patch to completely remove height if set as an empty string 👍

iRyusa pushed a commit that referenced this issue Dec 6, 2022
iRyusa added a commit that referenced this issue Dec 16, 2022
Co-authored-by: Maxime Brazeilles <maxime@derniercri.io>
@TechBill
Copy link

TechBill commented Feb 9, 2023

I am wondering if that patch allow the Outlook pixel line bug to appear its' ugly head. I post it over at - #2630

@iRyusa
Copy link
Member

iRyusa commented Apr 14, 2023

Don't think so.

But this has been release in 4.14.x

@iRyusa iRyusa closed this as completed Apr 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants