Magento 1.9 – How to Add an Image Attribute in Product Admin

attributesimagemagento-1.9

This feels like it should be really simple – but I can't seem to find the answer. I would like to add an attribute in magento where the user can upload an image.

I do not want this to appear as a thumbnail image (which seems to happen by default if it's placed in the 'images' section of the product management panel.

Can this be done and how? I've tried adding a 'media image' attribute but it does not show in the admin panel.

Any ideas on how this can be achieved?

Best Answer

Login to your Backend and go to Catalog->Attribute->Manage Attribute

Here create a new attribute and choose its input type "Media Image".

After create attribute assign to its in attribute set.

Once you assigned this then you can view this media attribute on Add product window in images tab.

How to call this attribute in product view page? using this code:

$hdr_img = $_product->getHeaderImg();`

if ($hdr_img) {
    $ban_img = $this->helper('catalog/image')->init($_product, 'header_img')->resize(1600, 312);

    echo '<img src="'.$ban_img.'"/>';
}

Here My attribute name is "header_img".