Ina Code Blog

bunch of code in one place
« Magento: How to activate new theme?
Magento: Add static block »


Jan
12

Magento: Change image background color

Posted by admin in Magento

If possible I always avoid modifing system core files, but in this case I couldn’t find any other solution. So to change your image background color open file /app/code/core/Mage/Catalog/Model/Product/Image.php and find:

protected $_backgroundColor  = array(255, 255, 255);

and replace it with:

protected $_backgroundColor  = array(0, 0, 0);

This will change the white background color to black. Change array(0, 0, 0) to whatever color you need.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

12 Responses to “Magento: Change image background color”

  1. Added by Magento Hosting on Jan at 15

    Never knew that - a very handy tip - bookmarking your site!

  2. Added by smily on Feb at 23

    I think you can override core files by using your ‘app/code/local’ folder, I’ve found it very handy as sometimes there is no option but to go into the code. This guy has more info on it: http://www.exploremagento.com/magento/override-a-magento-core-block-class.php

  3. Added by Andy on Apr at 28

    Hi,
    Thanks for your information.

    My website is built from Magento V1.1.8. Originally, all product image background color was white. However, on some day, all the color sudden change to BLACK. I never modify any files, no touch image.php.

    So, I really don’t know why it suddenly change to black color. Can u give me some help? My website is

    http://www.CocoMartini.com

    Many thanks.

    Regards,

    Andy
    all background colours

  4. Added by admin on May at 7

    Hi Andy
    check the same file and set the array to array(255, 255, 255) witch should give you white background on images.

  5. Added by Andy on May at 11

    Hi,
    Thanks for your reply. I double check the file and it default value is already

    protected $_backgroundColor = array(255, 255, 255);

    below is part of the file and you see that I never change the value and all are default setting. Any idea? Thanks in advance.

    regards,

    Andy

    *************

    class Mage_Catalog_Model_Product_Image extends Mage_Core_Model_Abstract
    {
    protected $_width;
    protected $_height;

    protected $_keepAspectRatio = true;
    protected $_keepFrame = true;
    protected $_keepTransparency = true;
    protected $_constrainOnly = false;
    protected $_backgroundColor = array(255, 255, 255);

    protected $_baseFile;
    protected $_newFile;
    protected $_processor;
    protected $_destinationSubdir;
    protected $_angle;
    protected $_watermarkPosition;
    protected $_watermarkWidth;
    protected $_watermarkHeigth;
    ****************

  6. Added by Andy on May at 22

    Finally I know my online boosktore problems. The webhost company say they change the server os from redhat to Debian. and no way to solve my case.

    CocoMartini.com College textbooks Online bookstore
    http://www.cocomartini.com

  7. Added by Andy on May at 26

    Although I know the reason. But there are no way to solve the image background problems for my college textbooks online bookstore.

    CocoMartini.com College textbooks Online bookstore
    http://www.cocomartini.com

  8. Added by Murat on May at 28

    How is it possible to use this for multiple shops in Magento?

  9. Added by Andy on Jun at 2

    Anyone have idea why there are different if my online bookstore hosted in redhat and debian?

    CocoMartini.com College textbooks Online bookstore
    http://www.cocomartini.com

  10. Added by admin on Jun at 3

    Andy try to put ‘background:#FFF;’ in your ‘.product-img-box .more-views li a’ class. Maybe this could work for you…

  11. Added by Andy Textbooks on Dec at 7

    Thanks admin, but where are
    ‘.product-img-box .more-views li a’

    Whick line for ‘background:#FFF;’?

    Thanks

  12. Added by admin on Dec at 9

    Andy this class is set in /skin/frontend/default/default/css/screen.css or in you custom theme if you are usin one.

Leave a Reply

Comment