You are here

function image_field_caption_get_image_fields in Image Field Caption 7

Same name and namespace in other branches
  1. 7.2 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.

2 calls to image_field_caption_get_image_fields()
image_field_caption_form_alter in ./image_field_caption.module
Implements hook_form_alter().
image_field_caption_form_submit_handler in ./image_field_caption.module
A #submit callback for node forms with image fields.

File

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

Code

function image_field_caption_get_image_fields($entity_type, $bundle) {
  $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;
    }
    if ($field['widget']['type'] != 'image_image') {
      continue;
    }
    $image_fields[$field_name] = $field;
  }
  if (empty($image_fields)) {
    return NULL;
  }
  return $image_fields;
}