6

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?

1

4 Answers 4

5

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".

2

Add new attribute from admin-end Catalog -> Attribute -> Manage Attribute -> Add New Attribute
Select media image under the dropdown Catalog Input Type for Store Owner
Now assign this newly created attribute to the attribute set and run indexation and clear cache.

2

I know it's already answered but I'm still writing as I think someone would have been here again. Yes you can upload and get any sized image instead of predefined thumbnail image.

Here are the steps below..

  1. Create a new attribute and choose its input type "Media Image".
  2. After creating attribute assign it in attribute set.
  3. Once you assigned this you can view this media attribute on Add/Edit product page in images tab like in the screenshot.For me it's Manufacturer Logo
  4. Don't forget to exclude it otherwise it'll be on the product gallery on the frontend.
  5. Use the code below to show that image where you like to.

    $manufacturer_logo = $this->helper('catalog/image')->init($_product, 'manufacturer_logo')->resize(600, 312);
    if($manufacturer_logo)
    echo '<img src="'.$manufacturer_logo.'"/>';
    

NOTE: for me attribute name is manufacturer_logo. Use ->resize(600, 312) function to resize desired size image.

0

You can find your answer here https://stackoverflow.com/questions/20965237/add-new-image-attribute-in-magento-backend-and-get-all-images-of-that-new-image

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.