function OliveroHooks::preprocessField
Same name and namespace in other branches
- 11.x core/themes/olivero/src/Hook/OliveroHooks.php \Drupal\olivero\Hook\OliveroHooks::preprocessField()
Implements hook_preprocess_HOOK() for field.
Attributes
#[Hook('preprocess_field')]
File
-
core/
themes/ olivero/ src/ Hook/ OliveroHooks.php, line 330
Class
- OliveroHooks
- Hook implementations for olivero.
Namespace
Drupal\olivero\HookCode
public function preprocessField(&$variables) : void {
$rich_field_types = [
'text_with_summary',
'text',
'text_long',
];
if (in_array($variables['field_type'], $rich_field_types, TRUE)) {
$variables['attributes']['class'][] = 'text-content';
$variables['#attached']['library'][] = 'olivero/olivero.table';
}
if ($variables['field_type'] == 'image' && $variables['element']['#view_mode'] == 'full' && !$variables["element"]["#is_multiple"] && $variables['field_name'] !== 'user_picture') {
$variables['attributes']['class'][] = 'wide-content';
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.