6

On Magento 2.0.2 I edited my custom theme view.xml (app/design/frontend/XXXXX/default/etc/view.xml) and added 2 properties for each images type : transparency and background.

My file now looks like this

<?xml version="1.0"?>
<view xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/view.xsd">
    <media>
        <images module="Magento_Catalog">
            ...
            <image id="cart_cross_sell_products" type="thumbnail">
                <width>250</width>
                <height>165</height>
                <transparency>false</transparency>
                <background>[237,237,237]</background>
            </image>
            ...
        </images>
    </media>
    ...
</view>

Looking at my file my background color should be set as this color (RGB 237,237,237 : hex #ededed). Actually that specific color is not applied but is black. Please take a look at the screenshot below: background color do not apply properly

What did I miss can someone lend a hand?

Edit : Still working on this issue. Some suggested to run bin/magento catalog:images:resize and bin/magento cache:flush but it did not help my cause.

Edit 2016-10-27 : I could not find a fix so I decided to extend the Image.php helper in a module and did something like this. It worked.

class Image extends \Magento\Catalog\Helper\Image{
    protected function setImageProperties() {
        parent::setImageProperties();
        $this->_getModel()->setBackgroundColor([237,237,237]);
        return $this;
    }
}

Edit 2017-12-15 : Warning : This issue has been fixed long time ago by Magento. I strongly suggest you update your Magento 2 sale platform to the latest available version at the moment you read this, not only this will fix plenty of issues you have but it will also improve performance and security by a great length.


2
  • Is this for all images or only these particular ones. Is it only for one page? If you're already in your theme I would use the .less files anyway. It makes more sense to have your style changes in LESS.
    – camdixon
    Jul 4 '16 at 15:17
  • This is for all product images, thumbnails and main. But I almost always cannot edit this background in my .less files because it is php generated and part of my image.
    – Dynomite
    Jul 4 '16 at 15:25
2

Try to Below Code

magento\module-catalog\Model\Product open Image.php File and change Background color protected $_backgroundColor = [255, 255, 255]; on Line no: 68.

1
  • It was already declared as such. :/ another idea?
    – Dynomite
    Jul 4 '16 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.