1. Home
  2. Prices
  3. Guided Tour
  4. New Shop
  5. Shop Review
  6. Ecommerce Marketing
  7. Ecommerce TV
  8. Magento Developers
  9. Portfolio
  10. Blog
  11. Contact
Home > Magento > Change Image Background Colour

Change Image Background Colour

Posted on: 8th Mar 2010 By: Adam Moss Leave a comment 2 Comments

Something that may irritate many Magento developers is the way that product images on both the product list and product view pages show white backgrounds when the image doesn’t fit the standard ratio. Rather than there being a simple way to change this in the configuration area, it’s up to us to find it by once again digging deep into the lower echelons of Magento’s core code. This time you need to open the file at the following path, *deep breath* :

app > code > core > Mage > Catalog > Model > Product > Image.php

There’s a line of code in there which is fairly self-explanatory:

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

The nine-digit RGB code determines which colour is shown by default in the product image backgrounds, and 255, 255, 255 is simply white, or #FFF. Using the eyedropper tool in a program like Photoshop is a good way of getting the RGB code for the colour that you require. Simply replace the numbers with the ones you require and upload. Job Done.

Before:

After:

  • Twitter
  • AIM
  • WordPress
  • LinkedIn
  • Facebook
  • StumbleUpon
  • Technorati Favorites
  • Delicious
  • Ping
  • Digg
  • Bebo
  • Reddit
  • MySpace
  • NewsVine
  • Google Bookmarks
  • Sphinn
  • Propeller
Categories: Magento Tags:

2 Responses to “Change Image Background Colour”

  1. kashif

    hi
    i am newly magento developer.
    i have a problem,i want to set background image in magento CMS pages which can be one or more.
    if any body have any idea abt that how i can add or set images in magento pages then plz tel me

    kashif

  2. Ken M

    Absolutely marvellous much better answer to the rest of the pages I’ve tried, only wish that this was the 1st page I tried, not the 15th :)

Post A Comment