function claro_preprocess_item_list__media_library_add_form_media_list in Drupal 8
Same name and namespace in other branches
- 9 core/themes/claro/claro.theme \claro_preprocess_item_list__media_library_add_form_media_list()
Implements hook_preprocess_item_list__media_library_add_form_media_list().
This targets each new, unsaved media item added to the media library, before they are saved.
File
- core/
themes/ claro/ claro.theme, line 1317 - Functions to support theming in the Claro theme.
Code
function claro_preprocess_item_list__media_library_add_form_media_list(array &$variables) {
foreach ($variables['items'] as &$item) {
$item['value']['preview']['#attributes']['class'][] = 'media-library-add-form__preview';
$item['value']['fields']['#attributes']['class'][] = 'media-library-add-form__fields';
$item['value']['remove_button']['#attributes']['class'][] = 'media-library-add-form__remove-button';
// #source_field_name is set by AddFormBase::buildEntityFormElement()
// to help themes and form_alter hooks identify the source field.
$fields =& $item['value']['fields'];
$source_field_name = $fields['#source_field_name'];
if (isset($fields[$source_field_name])) {
$fields[$source_field_name]['#attributes']['class'][] = 'media-library-add-form__source-field';
}
}
}