/** * Return element html code * * @return string */ public function getElementHtml() { $imageUrl = $this->_helperData->escapeHtml($this->_getImageUrl($this->getValue())); $htmlId = $this->_helperData->escapeHtml($this->getHtmlId()); $uploadUrl = $this->_helperData->escapeHtml($this->_getUploadUrl()); $html = '<input id="' . $htmlId . '_upload" type="file" name="image" ' . 'data-url="' . $uploadUrl . '" style="display: none;" />' . parent::getElementHtml() . '<img align="left" src="' . $imageUrl . '" id="' . $htmlId . '_image"' . ' title="' . $imageUrl . '" alt="' . $imageUrl . '" class="base-image-uploader"' . ' onclick="jQuery(\'#' . $htmlId . '_upload\').trigger(\'click\')"/>'; $html .= $this->_getJs(); return $html; }
/** * Return element html code * * @return string */ public function getElementHtml() { $htmlId = $this->_coreHelper->escapeHtml($this->getHtmlId()); $uploadUrl = $this->_coreHelper->escapeHtml($this->_getUploadUrl()); /** @var $product Mage_Catalog_Model_Product */ $product = $this->getForm()->getDataObject(); $gallery = $product->getMediaGalleryImages(); $html = '<input id="' . $htmlId . '-upload" type="file" name="image" ' . 'data-url="' . $uploadUrl . '" style="display:none" />' . '<input id="' . $htmlId . '" type="hidden" name="' . $this->getName() . '" />' . '<div id="' . $htmlId . '-container" data-main="' . $this->getEscapedValue() . '" ' . 'data-images="' . $this->_coreHelper->escapeHtml($this->_coreHelper->jsonEncode($gallery ? $gallery->toArray() : array())) . '">' . '<span id="' . $htmlId . '-upload-placeholder"></span>' . '<script id="' . $htmlId . '-template" type="text/x-jquery-tmpl">' . '<span class="container">' . '<span class="main-sticker">' . $this->helper('Mage_Catalog_Helper_Data')->__('Main') . '</span>' . '<span class="close">×</span>' . '<img class="base-image-uploader" src="${url}" data-position="${position}" alt="${label}" />' . '<div class="drag-zone">' . '<button class="make-main" type="button">' . $this->helper('Mage_Catalog_Helper_Data')->__('Make Main') . '</button>' . '</div>' . '</span>' . '</script>' . '</div>'; $html .= $this->_getJs(); return $html; }