You are here

function _taxonomy_image_available_fields in Taxonomy Image 7

Gets a list of available image fields for a taxonomy term reference field.

Parameters

$field: The field info array of the taxonomy term reference field.

Return value

An array of image fields attached to the references vocabulary, keyed by field name.

2 calls to _taxonomy_image_available_fields()
taxonomy_image_display_overview_form_submit in ./taxonomy_image.module
Form submission handler for field_ui_display_overview_form().
taxonomy_image_field_formatter_settings_form in ./taxonomy_image.module
Implements hook_field_formatter_settings_form().

File

./taxonomy_image.module, line 109
Implements a field formatter that can display image on referenced taxonomy terms.

Code

function _taxonomy_image_available_fields($field) {

  // Get the vocabulary name.
  $allowed_values = reset($field['settings']['allowed_values']);
  $vocabulary = $allowed_values['vocabulary'];
  $options = array();

  // Find all images fields that are attached.
  foreach (field_info_fields() as $field_name => $field) {
    if ($field['type'] != 'image') {
      continue;
    }
    if (empty($field['bundles']['taxonomy_term'])) {
      continue;
    }
    if (!in_array($vocabulary, $field['bundles']['taxonomy_term'])) {
      continue;
    }
    $options[$field_name] = $field_name;
  }
  return $options;
}