Wednesday, January 11, 2012

Product Image Re-size with out frame or removing white space

Hi,
Need to remove the white border around your images?

when we re-size product image we will get white space in border, so we can remove that white space when product image is re-sized

use this code to re-size the product image with out white space

<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(135)->keepFrame(FALSE); ?>


->constrainOnly(true) This will not resize an image that is smaller than the dimensions inside the resize() part.

->keepAspectRatio(true) This will not distort the height/width of the image.

->keepFrame(false) This will not put a white frame around your image.


<?php echo $this->helper('catalog/image')->init($_product, 'image')->constrainOnly(true)->keepAspectRatio(true)->keepFrame(false)->resize(350, null) ?>


This would resize your images to a max 350 width and constrain the height. If your image is taller than it is wide, you will end up with a nicely resized vertical image.

No comments:

Post a Comment