You are here

function image_field_caption_get_image_fields in Image Field Caption 7.2

Same name and namespace in other branches
  1. 7 image_field_caption.module \image_field_caption_get_image_fields()

Given an entity type and bundle name, this will return an associative array of image field info instances, keyed by image field machine names. Returns null if no image fields are found.

1 call to image_field_caption_get_image_fields()
image_field_caption_field_attach_update in ./image_field_caption.module
Implements hook_field_attach_update().

File

./image_field_caption.module, line 94
Provides a caption textarea for image fields.

Code

function image_field_caption_get_image_fields($entity_type = NULL, $bundle = NULL) {

  // TODO: As of Drupal 7.22 use field_info_field_map() instead of field_info_instances();
  $image_fields = array();
  $fields = field_info_instances($entity_type, $bundle);
  foreach ($fields as $field_name => $field) {

    // Skip any deleted and non image widget fields.
    if ($field['deleted'] == 1) {
      continue;
    }
    $field_info = field_info_field($field_name);
    if ($field_info['type'] != 'image') {
      continue;
    }
    $image_fields[$field_name] = $field;
  }
  return $image_fields;
}