You are here

function entity_reference_display_preprocess_field in Entity Reference Display 8

Implements hook_preprocess_HOOK().

File

./entity_reference_display.module, line 56
Entity Reference Display module.

Code

function entity_reference_display_preprocess_field(&$variables) {

  // Only for selected display mode formatter.
  if (isset($variables['element']['#formatter']) && $variables['element']['#formatter'] === 'entity_reference_display_default') {

    // Add display mode class for field wrapper.
    if (!empty($variables['element'][0]['#view_mode'])) {
      $class = 'erd-list--' . $variables['element'][0]['#view_mode'];
      $variables['attributes']['class'][] = Html::getClass($class);
    }
  }
}