Magento Product Image Resize - Magento Development Tutorial
No More Square (White Background) Magento Product Images
No More Square (White Background) Magento Product Images

No More Square (White Background) Magento Product Images

Published March 21, 2011 in Development
Introducing Wiz, a CLI Tool for Magento
March 8, 2011
Good vs. Great
March 22, 2011

Do you have a site with product images of varying proportions? It can be annoying when Magento gives you that white border to make your product image square. Here’s how customize what color that background is: just add backgroundcolor('000', '000', '000')before the resize() method

 

 

Better yet, get rid of the background using keepFrame(false):

Resizing after keepFrame(false) will resize the largest dimension. Don’t forget to delete your image height and width attributes (if need be)!

Here’s (most of) the places you’ll want to change these:

  • catalog/product/view/media.phtml
  • checkout/cart/item/default.phtml
  • catalog/product/list.phtml

There may be a few more but I bet you can find them. Enjoy your no longer square (white background) images!

4 Comments

  1. kkirchner says:

    No problemo! Glad I could help!

  2. Scott says:

    Aweomse! Thanks for that tip…been glaring at those white bars for a couple of hours now.

  3. Budi says:

    Hello,

    Can u give detailed folder path because i can’t find the folder arrangement

    I try to start from /APP/ but can’t find catalog

    Thank you

  4. Rouan says:

    Thanks, I’ve used the hex value to get it working. There seems to be another issue as 0xdd,0xdd,0xdd rendered black and not grey. Code snippet: ->backgroundColor(0xdc, 0xdc, 0xdc)->resize(135);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Recent PostsView all
November 4, 2021

How to prepare for holiday 2021: A winter shopping season like no other

With the holiday season comes a frenzy of online shopping activity. For retail businesses, this busy season is a critical period when an essential amount of […]
October 15, 2021

Classy Llama Wins 2021 Comparably Awards for Best Perks&Benefits, Best Work-Life Balance

Classy Llama, Springfield’s only full-service eCommerce agency, has been placed on the top 50 list for Comparably.com’s Best Perks&Benefits Award, as well as their Best Work-Life […]
September 15, 2021

Classy Llama Awarded #3 Best Place to Work by Biz417

Springfield, MO — Classy Llama has been awarded the number 3 spot on the Biz417 Best Places to Work Top 20 for 2021.  This award is […]