dotmailer / dotmailer-magento2-extension

The official Dotdigital for Magento2 extension
https://dotdigital.com/integrations/magento
MIT License
48 stars 63 forks source link

Email templates squash images that are not square #535

Closed CHallski closed 5 years ago

CHallski commented 5 years ago

The following template calls do not utilize Magento's keepAspectRatio and keepFrame options to gracefully resize images, resulting in non-square images being squashed:

This can be overridden with individual template files, but it would be nice if the base block were updated to default to keeping the original aspect ratio (and frame for centering): template handling method for basket.phtml below:

`<?php $_image = $_imagehelper->init($_product, 'product_small_image')->constrainOnly(false)->keepAspectRatio(true)->keepFrame(true)->resize(135); ?>

<?= $_image->getLabel() ?>

`

sta1r commented 5 years ago

Hello @CHallski. We find that with the Magento Luma demo theme, default behaviour for the small product image (135 x 135px) is for e.g. portrait images to be resized proportionally, with a white frame added. keepAspectRatio and keepFrame both default to true.

Large image mh01-gray_main_3-1

Resized small image mh01-gray_main_3

Perhaps there is something else in your setup that is squashing the images?

CHallski commented 5 years ago

Most likely:

<image id="product_small_image" type="small_image">
     <width>135</width>
     <height>135</height>
     <frame>false</frame>
</image>

in the theme view.xml for front-end display in general, which you're defaulting off of for the emails as well.

This may just be a case where we need to not have the frames on the front end due to CSS drop shadows, but we want them in the email to handle older clients and it's something we'll have to continue customizing if the out-of-the-box functionality is as intended.

sta1r commented 5 years ago

Indeed, we're just going off the vanilla Luma configuration for product_small_image: https://github.com/magento/magento2/blob/2.3-develop/app/design/frontend/Magento/luma/etc/view.xml#L113-L116. Theming for different contexts is left up to you guys to wrestle with! Good luck with it.