You are here

function entity_background_add_field_image in Entity background 7

Creates image field instance.

Parameters

type $entity_type: An entity type for the instance.

$bundle: A bundle for the instance.

$field_name: A field name.

$field_label: A field label.

$cardinality: Cardinality of the field. Set to 1 by default.

array $settings: An image settings array. Allows to set file options.

Return value

array An instance information array.

2 calls to entity_background_add_field_image()
entity_background_image_install in module/entity_background_image/entity_background_image.install
Implements hook_install().
entity_background_parallax_install in module/entity_background_parallax/entity_background_parallax.install
Implements hook_install().

File

includes/entity_background.fields_crud.inc, line 152
Fields CRUD functions.

Code

function entity_background_add_field_image($entity_type, $bundle, $field_name, $field_label, $cardinality = 1, $settings = array()) {
  $field = entity_background_get_field_image($field_name, $cardinality);

  // Default settings with all possible options.
  $settings_default = array();

  // Add default settings if some options are missing
  $settings += $settings_default;
  $instance = _entity_background_add_field($entity_type, array(
    'field_name' => $field['field_name'],
    'entity_type' => $entity_type,
    'bundle' => $bundle,
    'label' => $field_label,
    'required' => FALSE,
    'display' => array(
      'default' => array(
        'type' => 'hidden',
      ),
    ),
    'settings' => $settings,
  ));
  return $instance;
}