I have created a custom module with grid. Now trying to add the product thumbnails to this grid, but the $val in renderer file is empty and images don't show up (see image below).

[![custom module grid images don't show up][1]][1]

Here is the renderer file at ....\Block\Adminhtml\Template\Grid\Renderer\Image.php

class Cpstest_ProductComment_Block_Adminhtml_Template_Grid_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
    public function render(Varien_Object $row)
        return $this->_getValue($row);

    protected function _getValue(Varien_Object $row)
        $val = $row->getData($this->getColumn()->getIndex());
        $val = str_replace("no_selection", "", $val);
        $url = Mage::getBaseUrl('media') . 'catalog/product/' . $val;
        $out = "<img src=". $url ." width='60px'/>";
        return $out;

And the column code in Grid.php

$this->addColumn('image', array(
    'header'   => Mage::helper('catalog')->__('Image'),
    'align'    => 'left',
    'index'    => 'image',
    'width'    => '70',
    'renderer' => 'Cpstest_ProductComment_Block_Adminhtml_Template_Grid_Renderer_Image'

Thanks for any suggestions.

  • What is the content of $value? (just output this w/o img-tag)
    – sv3n
    May 16, 2017 at 22:11
  • I tried to print it out to see the value but nothing showed up. May 16, 2017 at 22:37
  • But I think it should be the name of the thumbnail. May 16, 2017 at 22:37
  • 1
    You can use Inspect Element in your browser, or right click the broken image then View Image Info (Firefox) or Copy image address (Chrome), to see what the image src is. May 16, 2017 at 22:52
  • 1
    looks like the image attribute hasn't been selected, check this post, especially the comment section. May 17, 2017 at 2:18

1 Answer 1


The image attribute isn't part of your custom collection. The easiest way to display the thumbnails is changing your render function to something like below, which loads a product based on productcomment_increment_id and get its thumnail.

public function render(Varien_Object $row)
    $product = Mage::getModel('catalog/product')->load($row->getProductcommentIncrementId());
    $url = Mage::getBaseUrl('media') . 'catalog/product/' . $product->getThumbnail();
    $out = "<img src=". $url ." width='60px'/>"; 
    return $out;
  • OMG @subroutines !!!! I tried dozens of different articles and codes and nothing seemed to work for 100%. Thank you SO MUCH! I wish I could +1000 your reputation! May 18, 2017 at 23:33
  • @bestwebdevs, glad to help:) May 19, 2017 at 5:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.