Fix: constrain image sizes in email notifications - #3637
Conversation
Constrain avatar and post images in email notifications so large remote avatars no longer render at native size and overflow the screen. Email clients often strip inline styles, so the size is now enforced with width/height attributes on the embed avatar, the new follower icon, and a global max-width rule in the shared email header style block. Fixes Automattic#3529
|
I am not sure if this pr fixes the issue properly. The report is about a mention, and it shows an avatar that is already around 100% max but this full display size is already too big. I think your PR is a nice improvement, but the issue is still existent!? |
- Add inline max-width to the embed avatar so oversized remote avatars stay at 48px even when email clients strip style blocks - Add explicit dimensions to the embed featured image so post images fit the email width instead of overflowing Addresses PR feedback. Refs Automattic#3529
|
@pfefferle thanks for the feedback. I checked the mention path (new-dm and new-mention both render the embed) and found two things that were still missing. The avatar in templates/embed.php now has inline The featured post image in templates/embed.php now has I kept Commit: 0bf2ae5 Would appreciate your review of this follow-up when you have a chance. |
Fixes #3529
Proposed changes:
img { max-width: 100%; height: auto; }rule to the shared email header style block so every image in every email template fits the email width.width/heightattributes to the embed avatar (48px) and the new follower icon (64px) so the size holds even when styles are dropped. These match the sizes the existing CSS already enforces, so the public embed output is unchanged.Other information:
Logged-in test of email templates can't be automated here, so the fix was verified against the repository CSS and template output. The changes are template and CSS-only with no logic change, so no PHPUnit coverage is added.
Testing instructions:
npm run env-start).<style>blocks (for example Gmail).Changelog entry
A changelog entry was added manually as
.github/changelog/fix/3529-avatar-email-max-width.Changelog Entry Details
Significance
Type
Message
Fixed oversized avatar and post images in email notifications from remote users. Avatars and inline images now resize to fit the email width instead of overflowing the screen.