Add New Product Image Type (Attribute) in Magento

I am trying to add a new image type in the product admin panel. I created a new attribute (hero_banner) set it’s type to media image (similar to how the thumbnail image and small_image have been set up). I then added it to the Default attribute set under images. It appears fine in the admin panel and allows you to assign images as the hero but then when I try and echo the image path into the phtml the templates stop rendering. The code I am using to echo the image is below:

<?php echo $this->helper('catalog/image')->init($_product, 'hero_banner'); ?>

This is being done within a product foreach iteration so I have the $_product variable and I am able to echo other images fine (such as thumbnail, small_image etc). What am I doing wrong?

One thought on “Add New Product Image Type (Attribute) in Magento”

  1. I think you have to select this attribute too in your collection like this before the collection is actually loaded:

    $productCollection->addAttributeToSelect('hero_banner');
    

    It works fine on my code, but I dont know if you already have rewrited the block where your collection is defined (it won’t work in your template since the collection is already loaded there)
    Maybe you can configure your hero_attribute to add this addAttributeToSelect directly in Magento back office, I’ll have a look

    Edit: Ok, I think I’ve got it, you won’t have to worry about collection & rewrites 🙂
    If you use this attribute on product listing, you have to set the property “visible on product listing” to true to your image attribute (in the admin panel attribute management)

    Good luck

Leave a Reply

Your email address will not be published. Required fields are marked *