Email logo to png extension#16779
Conversation
| $this->setPlaceholder('background', $background); | ||
|
|
||
| $logo = $this->modx->getOption('login_logo', null, $managerUrl . 'templates/' . $managerTheme . '/images/modx-logo-color.svg', true); | ||
| $logo = $this->modx->getOption('login_logo', null, $managerUrl . 'templates/' . $managerTheme . '/images/modx-logo-color.png', true); |
There was a problem hiding this comment.
This is actually the wrong place to change this, as this is for the web UI not the email html. You need to alter the email template at manager/templates/default/email/default.tpl. But, it'd be preferable to provide the png as a fallback to the svg, maybe trying something like:
<img
src="{$_config.url_scheme}{$_config.http_host}{$_config.manager_url}templates/default/images/modx-logo-color.png"
alt="{$_config.site_name}"
srcset="{$_config.url_scheme}{$_config.http_host}{$_config.manager_url}templates/default/images/modx-logo-color.svg"
>I'd also suggest providing the PNG at a minimum of 2x size (~440px wide), maybe even 3x (~650px). It's sized down in the css, so no worries on physical size; this will give it a sharper appearance on the mostly high-dpi devices the message will be read with.
| $this->setPlaceholder('background', $background); | ||
|
|
||
| $logo = $this->modx->getOption('login_logo', null, $managerUrl . 'templates/' . $managerTheme . '/images/modx-logo-color.svg', true); | ||
| $logo = $this->modx->getOption('login_logo', null, $managerUrl . 'templates/' . $managerTheme . '/images/modx-logo-color.png', true); |
What the PR does
The issue: wrong targetThe email template at {if $_config.login_logo}
<img src="{$_config.login_logo}" alt="{$_config.site_name}"/>
{else}
<img src="{$_config.url_scheme}{$_config.http_host}{$_config.manager_url}templates/default/images/modx-logo-color.svg" alt="{$_config.site_name}"/>
{/if}When Recommended approach1. Update the email template Change the fallback in <img src="{$_config.url_scheme}{$_config.http_host}{$_config.manager_url}templates/default/images/modx-logo-color.png" alt="{$_config.site_name}"/>2. Optional: PNG with SVG fallback for capable clients As @smg6511 suggested, use PNG as the main source and SVG in <img src="{$_config.url_scheme}{$_config.http_host}{$_config.manager_url}templates/default/images/modx-logo-color.png"
alt="{$_config.site_name}"
srcset="{$_config.url_scheme}{$_config.http_host}{$_config.manager_url}templates/default/images/modx-logo-color.svg" />3. Login page The login page can stay on SVG (better for web: scalable, smaller). If you prefer consistency, keep the PNG default in 4. PNG resolution For retina displays, consider a 2x (~440px) or 3x (~650px) PNG. The CSS keeps the display size at ~217px, so a larger source will look sharper on high-DPI screens. Summary
Verdict: The PNG asset is fine, but the fix must be applied in |
What does it do?
I changed the extension from .svg to .png and uploaded a new png logo
Why is it needed?
Some email providers for example Gmail are blocking .svg images in their email. So the image won't load if you view it in gmail.
How to test
Use the "Let the user choose their own password via email" option for example and check the email in gmail. The image won't load