Skip to content

Instantly share code, notes, and snippets.

@xcommerce-gists
Created January 25, 2014 15:42
Show Gist options
  • Save xcommerce-gists/8618236 to your computer and use it in GitHub Desktop.
Save xcommerce-gists/8618236 to your computer and use it in GitHub Desktop.
Sample Magento administrative image-only form element
<?php
/**
* Custom image form element that generates correct thumbnail image URL
*
* @author Magento
*/
class Magentostudy_News_Block_Adminhtml_News_Edit_Form_Element_Image extends Varien_Data_Form_Element_Image
{
/**
* Get image preview url
*
* @return string
*/
protected function _getUrl()
{
$url = false;
if ($this->getValue()) {
$url = Mage::helper('magentostudy_news/image')->getBaseUrl() . '/' . $this->getValue();
}
return $url;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment