Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Custom module image field not displaying in admin form
Jr. Member
Total Posts:  1
Joined:  2012-09-27

I cannot workout how to correctly set the url for an image field on the edit form. I can create a new item and upload an image file to the following directory

$path = Mage::getBaseDir(’media’) . DS . ‘carousel’ . DS;

Yet when editing an item, the image field has the following url


instead of


How can I get the correct image url?

Magento Community Magento Community
Magento Community
Magento Community
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania

in order to work with a custom path you need to write a custom renderer for the field.
Create this class:

class Company_Module_Block_Adminhtml_Entity_Helper_Image extends Varien_Data_Form_Element_Image{
protected function _getUrl(){
        if (
$this->getValue()) {
=  Mage::getBaseUrl(’media’) . â€˜/carousel/’.$this->getValue();
return $url;
replace ‘Company’, ‘Module’ and ‘Entity’ to your own namespace, module name and entity name.
now you have to tell Magento to use your new renterer for image fields.

In the class ‘Company_Module_Block_Adminhtml_Entity_Edit_Tab_Form’ class (replace again the generic values with your own), assuming you have one, and you should, in the method _prepareForm() add this line:

right before calling the first $fieldset->addField().
Replace again ‘company’…

In order for this to work make sure that your field is of type ‘image’ and not file.

if you want to avoid in the future this kind of problems try using this module creator:
Details about if are found here:
It’s still in beta and might have some bugs, but it saves you a lot of time.


Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top