*/ class Varien_Data_Form_Element_Image extends Varien_Data_Form_Element_Abstract { /** * Constructor * * @param array $data */ public function __construct($data) { parent::__construct($data); $this->setType('file'); } /** * Return element html code * * @return string */ public function getElementHtml() { $html = ''; if ((string)$this->getValue()) { $url = $this->_getUrl(); if( !preg_match("/^http\:\/\/|https\:\/\//", $url) ) { $url = Mage::getBaseUrl('media') . $url; } $html = '' . '' . $this->getValue() . '' . ' '; } $this->setClass('input-file'); $html .= parent::getElementHtml(); $html .= $this->_getDeleteCheckbox(); return $html; } /** * Return html code of delete checkbox element * * @return string */ protected function _getDeleteCheckbox() { $html = ''; if ($this->getValue()) { $label = Mage::helper('core')->__('Delete Image'); $html .= ''; $html .= 'getDisabled() ? ' disabled="disabled"': '') . '/>'; $html .= ''; $html .= $this->_getHiddenInput(); $html .= ''; } return $html; } /** * Return html code of hidden element * * @return string */ protected function _getHiddenInput() { return ''; } /** * Get image preview url * * @return string */ protected function _getUrl() { return $this->getValue(); } /** * Return name * * @return string */ public function getName() { return $this->getData('name'); } }