You are here

function imageinfo_cache_detect_image_widget in Imageinfo Cache 7.3

Detect if the widget is an image type.

Parameters

array $widget: Field widget array.

Return value

string Returns what type of imagefield it is or a blank string if not found.

3 calls to imageinfo_cache_detect_image_widget()
imageinfo_cache_entity_insert in ./imageinfo_cache.module
Implements hook_entity_insert().
imageinfo_cache_field_widget_form_alter in ./imageinfo_cache.module
Implements hook_field_widget_form_alter().
imageinfo_cache_get_fields_with_images in ./imageinfo_cache.inc
Get all fields that contain an image.

File

./imageinfo_cache.module, line 382
Imageinfo Cache module.

Code

function imageinfo_cache_detect_image_widget(array $widget) {
  $return = '';
  if (!empty($widget['type']) && $widget['type'] === 'image_image') {
    $return = 'core';
  }
  elseif (!empty($widget['type']) && $widget['type'] === 'image_miw') {
    $return = 'multiupload imagefield widget';
  }
  elseif (!empty($widget['settings']['allowed_types']['image'])) {
    $return = 'media module';
  }
  elseif (module_exists('media') && !empty($widget['type']) && $widget['type'] === 'media_generic') {
    $return = 'media module';
  }
  elseif (!empty($widget['type']) && $widget['type'] === 'imagefield_crop_widget') {
    $return = 'imagefield crop';
  }
  elseif (!empty($widget['type']) && strpos($widget['type'], 'image') === 0) {

    // Use the fallback if the type starts with image.
    $return = 'image fallback';
  }

  // Allow other modules to modify this info.
  // Call hook_imageinfo_cache_detect_image_widget_alter()
  drupal_alter('imageinfo_cache_detect_image_widget', $return, $widget);
  return $return;
}