*/ class TBT_Enhancedgrid_Block_Widget_Grid_Column_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract { protected static $showImagesUrl = null; protected static $showByDefault = null; protected static $width = null; protected static $height = null; public function __construct() { if(self::$showImagesUrl == null) self::$showImagesUrl = (int)Mage::getStoreConfig('enhancedgrid/images/showurl') === 1; if(self::$showByDefault == null) self::$showByDefault = (int)Mage::getStoreConfig('enhancedgrid/images/showbydefault') === 1; if(self::$width == null) self::$width = Mage::getStoreConfig('enhancedgrid/images/width'); if(self::$height == null) self::$height = Mage::getStoreConfig('enhancedgrid/images/height'); } /** * Renders grid column * * @param Varien_Object $row * @return string */ public function render(Varien_Object $row) { return $this->_getValue($row); } /* public function renderProperty(Varien_Object $row) { $val = $row->getData($this->getColumn()->getIndex()); $val = Mage::helper('imagebyurl')->getImageUrl($val); $out = parent::renderProperty(). ' onclick="showImage('.$val.')" '; return $out; } */ protected function _getValue(Varien_Object $row) { $dored = false; if ($getter = $this->getColumn()->getGetter()) { $val = $row->$getter(); } $val = $val2 = $row->getData($this->getColumn()->getIndex()); $val = str_replace("no_selection", "", $val); $val2 = str_replace("no_selection", "", $val2); $url = Mage::helper('enhancedgrid')->getImageUrl($val); if(!Mage::helper('enhancedgrid')->getFileExists($val)) { $dored =true; $val .= "[!]"; } if(strpos($val, "placeholder/")) { $dored = true; } $filename = substr($val2, strrpos($val2, "/")+1, strlen($val2)-strrpos($val2, "/")-1); if(!self::$showImagesUrl) $filename = ''; if($dored) { $val = "$filename"; } else { $val = "". $filename .""; } if(empty($val2) ) { $out = "
" . $this->__("(no image)") . "
"; } else { $out = $val. '
'; } if(self::$showByDefault && !empty($val2) ) { $out .= " self::$width) { $out .= "height='". self::$height ."' "; } $out .=" />"; } //die( $this->helper('catalog/image')->init($_product, 'small_image')->resize(135, 135)); $out .= '
'; return $out; } }