function bartik_preprocess_links__media_library_menu in Drupal 9
Implements hook_preprocess_links__media_library_menu().
This targets the menu of available media types in the media library's modal dialog.
@todo Do this in the relevant template once https://www.drupal.org/project/drupal/issues/3088856 is resolved.
File
- core/
themes/ bartik/ bartik.theme, line 155 - Functions to support theming in the Bartik theme.
Code
function bartik_preprocess_links__media_library_menu(array &$variables) {
foreach ($variables['links'] as &$link) {
// This conditional exists because the media-library-menu__link class is
// currently added by Classy, but Bartik will eventually not use Classy as a
// base theme.
// @todo remove conditional, keep class addition in
// https://drupal.org/node/3110137
// @see https://www.drupal.org/node/3109287
// @see classy_preprocess_links__media_library_menu()
if (!isset($link['link']['#options']['attributes']['class']) || !in_array('media-library-menu__link', $link['link']['#options']['attributes']['class'])) {
$link['link']['#options']['attributes']['class'][] = 'media-library-menu__link';
}
}
}