The default Magento install has several media gallery attributes allowing you to choose a thumbnail, small, and base image for a product’s image gallery. I’ve often had the need to use additional image types. For instance, my latest project required the addition of a header banner for product detail pages.
It is possible to simply insert two rows into the eav_attribute and eav_attribute_group tables to accomplish this, but it will be lost if your database ever is. Here’s how to implement such a feature properly.
First, we’ll create a standard Magento module directory structure inside app/code/local. Here’s a screenshot, just create blank files as placeholders for everything you see, we’ll edit them later. Change the name of the company (Company) and module (Customized) as you desire.

Alright Dudley, make yours like mine.
This is a pretty sparse module. The only thing it does is install some attributes for us. First, let’s look at the configuration file, config.xml.
<config>
<modules>
<company_customized>
<version>0.1.0</version>
</company_customized>
</modules>
<global>
<models>
<customized>
<class>Company_Customized_Model</class>
<resourcemodel>customized_resource_eav_mysql4</resourcemodel>
</customized>
<customized_resource_eav_mysql4>
<class>Company_Customized_Model_Resource_Eav_Mysql4</class>
</customized_resource_eav_mysql4>
</models>
<resources>
<customized_setup>
<setup>
<module>Company_Customized</module>
<class>Company_Customized_Model_Resource_Eav_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</customized_setup>
</resources>
</global>
</config>
Here, we’re essentially setting up a skeletal EAV resource for Magento, there’s no model, just the setup file that will be instantiated when the install file in sql/customized_setup is run by Magento. In Setup.php, we define our entities. In our case, we’re adding an entity to the product model under the Images group. For clarity, here’s Setup.php.
class Company_Customized_Model_Resource_Eav_Mysql4_Setup
extends Mage_Eav_Model_Entity_Setup
{
public function getDefaultEntities
()
{
return array(
'catalog_product' => array(
'entity_model' => 'catalog/product',
'attribute_model' => 'catalog/resource_eav_attribute',
'table' => 'catalog/product',
'attributes' => array(
'banner_image' => array(
'group' => 'Images',
'type' => 'varchar',
'frontend' => 'catalog/product_attribute_frontend_image',
'label' => 'Banner Image',
'input' => 'media_image',
'class' => '',
'source' => '',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute
::SCOPE_STORE,
'visible' => true,
'required' => false,
'user_defined' => false,
'default' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
)
)
)
);
}
}
All this file does is define a function (getDefaultEntities()) that returns an array of entities. This function is called by installEntities() within the install file, which we’ll look at last. mysql4-install-0.1.0.php is only two lines. Notice how the version number from config.xml corresponds to the file name.
$installer = $this;
$installer->installEntities();
To get the ball rolling, you need to add a module configuration file in app/etc/modules. In my case, it’s named Company_All.xml. Here’s the contents.
<config>
<modules>
<company_customized>
<active>true</active>
<codepool>local</codepool>
</company_customized>
</modules>
</config>
Once you’re all set, disable or refresh Magento’s EAV types and attributes cache in the administration interface under System -> Cache Management. After you refresh the page, you should see something like this when you edit a product’s images.

Look Ma, a banner image radio!
Here is a zip file containing everything discussed. This code was used with Magento 1.2.0.3.