1.20.x image.tokens.inc _image_token_get_image_fields()

Helper function to find all image fields.

Return value

array: An array containing all image fields. Keys of the array is an identifier made up of field_type:field_name:entity_type:bundle. Values are the human-readable name of the field.

File

modules/image/image.tokens.inc, line 270
Builds placeholder replacement tokens for image styles.

Code

function _image_token_get_image_fields() {
  $image_fields = array();

  $fields = field_info_fields();
  foreach ($fields as $field) {
    foreach ($field['bundles'] as $entity_type => $bundles) {
      foreach ($bundles as $bundle) {
        $key = $field['type'] . ':' . $field['field_name'] . ':' . $entity_type . ':' . $bundle;
        $label = $entity_type . ': ' . $bundle . ': ' . $field['field_name'];
        if ($field['type'] == 'image') {
          $image_fields[$key] = $label;
        }
      }
    }
  }

  return $image_fields;
}