function ClaroHooks::preprocessViewsViewFieldsMediaLibrary

Same name and namespace in other branches
  1. 11.x core/themes/claro/src/Hook/ClaroHooks.php \Drupal\claro\Hook\ClaroHooks::preprocessViewsViewFieldsMediaLibrary()

Implements hook_preprocess_HOOK() for views_view_fields__media_library.

This targets each rendered media item in the grid display of the media library's modal dialog.

Attributes

#[Hook('preprocess_views_view_fields__media_library')]

File

core/themes/claro/src/Hook/ClaroHooks.php, line 1181

Class

ClaroHooks
Hook implementations for claro.

Namespace

Drupal\claro\Hook

Code

public function preprocessViewsViewFieldsMediaLibrary(array &$variables) : void {
  // Add classes to media rendered entity field so it can be targeted for
  // styling. Adding this class in a template is very difficult to do.
  if (isset($variables['fields']['rendered_entity']->wrapper_attributes)) {
    $variables['fields']['rendered_entity']->wrapper_attributes
      ->addClass('media-library-item__click-to-select-trigger');
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.