Media entity browser view css not getting triggered

Created on 19 June 2019, about 5 years ago
Updated 13 July 2023, 12 months ago

Problem

Media Entity Browser CSS is not applying on media library page. All the images are showing as list instead of grid of images in row.

Issue
I Debug and found that the issue is with the css, most of the css added in media_entity_browser.view.css file are using 'view-media-entity-browser-view' class for tree, but this class is updated in view to 'view-media-entity-browser' and therefor the css is not having any effect.

Solution

This solution is very simple; update view class in all the css added in media_entity_browser.view.css file to 'view-media-entity-browser'.

For a quick fix I've used hook_prepocess_views_view() and added the old class to the view:

/**
 * Implements hook_preprocess_views_view().
 */
function MY_MODULE_preprocess_views_view(&$variables) {
  if ($variables['view']->id() === 'media_entity_browser') {
    $variables['attributes']['class'][] = 'view-media-entity-browser-view';
  }
}
🐛 Bug report
Status

Active

Component

User interface

Created by

🇮🇳India rahul patidar

Live updates comments and jobs are added and updated live.
  • CSS

    It involves the content or handling of Cascading Style Sheets.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom joehuggans Harrogate, UK

    Drupal 10 did the following:

    function MY_MODULE_preprocess_views_view(&$variables) {
      if ($variables['view']->id() === 'MACHINE_NAME_OF_VIEW') {
        $variables['#attached']['library'][] = 'media_entity_browser/view';
      }
    }
Production build 0.69.0 2024