1. Firstly we have to add the following code snippet in _prepareColumns() function, in Grid.php(path: code/local/Packagename/Modulename/Block/Adminhtml/Modulename/Grid.php). Here we use the local path you can use community.
<?php
$this->addColumn(‘modulenameimage’, array(
‘header’ => Mage::helper(‘modulename’)->__(‘Image’),
‘align’ => ‘left’,
‘index’ => ‘modulenameimage’,
‘renderer’ => ‘modulename/adminhtml_modulename_renderer_image’,
‘width’ => ‘107’
));
?>
Note: Here modulenameimage is the custom attribute.
2. Here we can see that a renderer block(adminhtml_modulename_renderer_image), so now our task is to create that block in Packagename_Modulename_Block_Adminhtml_Modulename_Renderer_Image file as below:
<?php
class Packagename_Modulename_Block_Adminhtml_Modulename_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
public function render(Varien_Object $row) {
$html = ‘<img ‘;
$html .= ‘id=”‘ . $this->getColumn()->getId() . ‘” ‘;
$html .= ‘width=”‘ . $this->getColumn()->getWidth() . ‘” ‘;
$html .= ‘src=”‘ . Mage::getBaseUrl(“media”) . ‘images/’ . $row->getData($this->getColumn()->getIndex()) . ‘”‘;
$html .= ‘class=”grid-image ‘ . $this->getColumn()->getInlineCss() . ‘”/>’;
return $html;
}
}
?>
These are all you need to do to show thumbnail image in grid view. Now you can the grid for that particular module and see the image there. You can change the custom column, image path, width, height as you desire.