You are here

function asin_preprocess_field in Amazon Product Advertisement API 7.2

Implements hook_preprocess_field().

File

asin/asin.module, line 564
Defines a field type for referencing an Amazon product.

Code

function asin_preprocess_field(&$variables, $hook) {

  // Add locale class to the Asin fields.
  if ($variables['element']['#field_type'] == 'asin') {
    $field_name = $variables['element']['#field_name'];
    $bundle = $variables['element']['#bundle'];
    $entity_type = $variables['element']['#entity_type'];
    $field_instance = field_info_instance($entity_type, $field_name, $bundle);
    if (isset($field_instance['widget']['settings']['widget_settings']['locale'])) {
      $locale = $field_instance['widget']['settings']['widget_settings']['locale'];
    }
    else {
      $locale = variable_get('amazon_default_locale');
    }
    $variables['classes_array'][] = 'locale-' . strtolower($locale);
  }
}