Wednesday, 21 May 2014

Magento | Resize product image

Magento | Resize product image.

Resizing of the images is the issue we are getting many times while we are optimizing and customizing the magento site. You can resize the media images by the following code.


 $src = Mage::helper('catalog/image')->init($_product, 'small_image')->resize(170, 120);


Just follow the above code to optimize and resize your images.
Where $_product: is the object of product
'small_image' :  show the size of image your required as output.
and inside the Resize() function you can insert the parameters where the first parameter is width and next one is the height of the image.
If image is not found in the product then it will show you the default placeholder image at that place.

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Great Read! I am impressed on how you make your article easy to understand. I'll come back for more :D

    Japs Buidon is a Social Media Specialist and belongs to a team of Magento Developer in Florida. For more tutorial and tips you can follow him here -> http://alwaysopencommerce.com/

    ReplyDelete