你必須創建在Adminhtml文件夾說渲染一個塊文件,並可以創建一個文件稱Image.php
在該文件中寫一個函數
public function render(Varien_Object $row){
$mediaurl=Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
$value = $row->getData($this->getColumn()->getIndex());
return '<p style="text-align:center;padding-top:10px;"><img src="'.$mediaurl.DS.$value.'" style="width:100px;height:200px;text-align:center;"/></p>';
}
的調用這個函數在grid.php
$this->addColumn("thumbnailimage", array(
"header" => Mage::helper("modulename")->__("Image"),
"index" => "thumbnailimage",
"renderer" =>"Companyname_Modulename_Block_Adminhtml_Renderer_Image",
));
剛一說明,在Image.php渲染器應該擴展'Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract' – gregdev