Media library css is broken with the Gin theme

Created on 10 August 2022, about 2 years ago
Updated 20 November 2023, 12 months ago

Problem/Motivation

This problem happend after changing our admin theme to Gin. The media library styling broke after this change, thumbnails are too small to be practical:

While debugging i saw that the following code was the problem for now. This code was part of the styling from the media entity browser.

@media screen and (min-width:37.5em) { /* 600px */
  .view-media-entity-browser-view .views-row {
    width: 50%;
    float: left;
  }
}

@media screen and (min-width:62.5em) { /* 1000px */
  .view-media-entity-browser-view .views-row {
    width: 33.333%;
  }
}

After removing this code with a patch the styling was not broken anymore:

I don't know the consequences with other admin themes and if this is actually a problem for the developers of the theme Gin.

Steps to reproduce

  • Install Gin and Media Entity Browser.
  • Enable the module and set the Gin theme to default admin theme
  • Add an image from the media library. You can see that styling is broken. See the uploaded images as an example.

Proposed resolution

To get to a final resolution, we will need to make the applied styling depend on the active theme.

Remaining tasks

  • Decide on solution
  • Turn into a pull request
  • Review
  • Merge

User interface changes

Visual bug in the media entity browser in Gin is fixed.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Needs work

Component

Code

Created by

🇳🇱Netherlands ahmetburkan Utrecht

Live updates comments and jobs are added and updated live.
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 States inversed

    I was having this problem as well and had a similar solution in place (based on this issue). However, after recent Drupal and module updates, my fix introduced a regression error. I started seeing a problem where the Media Library thumbnails were full width in the modal (giant images). In particular, the Media Library can be accessed in the Form Display widget for media entity reference fields or in the CKEditor media embed browser. The responsive CSS code would fix the reference fields but break the CKEditor embed browser.

    Ultimately, I now only need the following and removed the various media query workarounds:

    .media-library-item--grid {
      width: 100%;
    }
    
  • 🇺🇸United States inversed

    And a follow up to my last post - unfortunately, this problem is still around for some situations. So I still need to explore a more refined approach.

  • 🇫🇷France netsliver Chelles

    Patch with force padding to view more media part

  • 🇺🇸United States inversed

    With some help, it looks like the fix is to scope the 100% width more specifically to gin.

    .gin-entity-browser .media-library-item--grid {
      width: 100%;
    }
    

    The main takeaway is:

    • Prevents making thumbnails on main Media Library page giant: /admin/content/media-grid
    • Fixes thumbnails in Media Library browser in CKEditor4 media entity embed
    • Fixes thumbnails in Media Library browser in Media Entity Reference fields

    Note that I happened to have an old field still using the Media Entity Browser widget (not Media Library). That one was still showing the tiny thumbnails. So the solution was to set this to use the same widget as all the other Media Entity Reference fields.

  • First commit to issue fork.
  • Assigned to shivam_tiwari
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 8.1 & MySQL 8
    last update over 1 year ago
    4 fail
  • @shivam_tiwari opened merge request.
  • Issue was unassigned.
  • 🇪🇸Spain eduardo morales alberti Spain, 🇪🇺

    Same error here

Production build 0.71.5 2024