Product images are typically rendered using the
Mage_Catalog_Helper_Image class in the following way:
- Create an instance of the helper image class:
$imageHelper = Mage::helper('catalog/image');
- Provide the instance with the product and image attribute code that you want to render:
- Specify width and height to which the image should be resized:
$imageHelper->__toString() to generate the image in
media/catalog/product/cache (it it doesn't already exist) and return an url to it. When calling this method in a phtml, you can just use
<?php echo $imageHelper ?>, which automatically triggers the
In most cases, the above steps are executed inline:
<?php echo Mage::helper('catalog/image')->init($product, $imageAttributeCode)->resize($width, $height) ?>
So for the case of rendering a 75x75 thumbnail of the products shown on the sales order view page, you can add the following to a template override of
src="<?php echo Mage::helper('catalog/image')->init($_item->getProduct(), 'thumbnail')->resize(75, 75) ?>"
alt="<?php echo $this->escapeHtml($_item->getName()) ?>"