function uc_catalog_add_image_field in Ubercart 7.3
Same name and namespace in other branches
- 8.4 uc_catalog/uc_catalog.module \uc_catalog_add_image_field()
Sets up a default image field on the Catalog vocabulary.
2 calls to uc_catalog_add_image_field()
- uc_catalog_enable in uc_catalog/
uc_catalog.install - Implements hook_enable().
- uc_catalog_repair_field in uc_catalog/
uc_catalog.admin.inc - Repairs the catalog taxonomy field if it is lost or deleted.
File
- uc_catalog/
uc_catalog.module, line 606 - Ubercart Catalog module.
Code
function uc_catalog_add_image_field() {
$field = field_info_field('uc_catalog_image');
if (!$field) {
$field = array(
'field_name' => 'uc_catalog_image',
'type' => 'image',
);
field_create_field($field);
}
$instance = field_info_instance('taxonomy_term', 'uc_catalog_image', 'catalog');
// Only add the instance if it doesn't exist. Don't overwrite any changes.
if (!$instance) {
$label = t('Image');
$instance = array(
'field_name' => 'uc_catalog_image',
'entity_type' => 'taxonomy_term',
'bundle' => 'catalog',
'label' => $label,
'widget' => array(
'type' => 'image_image',
),
'display' => array(
'full' => array(
'label' => 'hidden',
'type' => 'image',
'settings' => array(
'image_link' => 'content',
'image_style' => 'uc_category',
),
),
),
);
field_create_instance($instance);
}
}