1

I am using Magento 1.9 and the RWD theme. My product images are rectangle, being taller than they are wide, however Magento shows them as square. How do I change this?

My largest image size is 1000x600 (Height x Width)

1 Answer 1

1

Looking at Mage_Catalog_Helper_Image->resize

/**
 * Schedule resize of the image
 * $width *or* $height can be null - in this case, lacking dimension will be calculated.
 *
 * @see Mage_Catalog_Model_Product_Image
 * @param int $width
 * @param int $height
 * @return Mage_Catalog_Helper_Image
 */
public function resize($width, $height = null)
{
    $this->_getModel()->setWidth($width)->setHeight($height);
    $this->_scheduleResize = true;
    return $this;
}

So resize by ->keepFrame(true)->resize(null, 300)

3
  • It took me a while to figure this out, but I had to edit list.phtml, find the code for //Grid Mode, and change ->resize($_imgSize) to ->resize(200, $_imgSize) to get correct proportions for my images. Putting 'null' instead of 200 resulted in no change to images.
    – k1rah
    Mar 11, 2015 at 5:03
  • Ah, you should also set ->keepFrame(true) before calling resize. Than the width is automatically calculated
    – Jeroen
    Mar 11, 2015 at 7:17
  • 1
    Thanks! I actually had to use ->keepFrame(false), but it works perfect. The images now match how they look on list mode.
    – k1rah
    Mar 13, 2015 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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