This is the standard code for resizing images:
|
1 |
<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(100) ?> |
If an image is rectangular, a white border appears around it. Sometimes that is undesirable. To change this behavior, use the following methods:
- constrainOnly(true) (prevents resizing images that are smaller than the dimensions specified in resize(…))
- keepAspectRatio(true) (preserves the aspect ratio of the image)
- keepFrame(false) (removes the white border around the image)
The revised code could look like this:
|
1 2 |
<?php echo $this->helper('catalog/image')->init($_product, 'image') ->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)->resize(100) ?> |
Removing white borders around rectangular product images
Need help implementing this solution, or still looking for a fix to your Magento problem? Get in touch and I will be happy to help with your project.