Library drowl_media/bundle_slideshow & drowl_media/bundle_documents aren't loaded

Created on 15 June 2023, over 1 year ago

Checking for bundle document to load the slideshow bundle styles seems slightly wrong.. let's fix this.

    if($bundle == 'document'){
      $attachments['#attached']['library'][] = 'drowl_media/bundle_slideshow';
    }
🐛 Bug report
Status

Fixed

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @thomas.frobieter
  • So.. we probably have multiple issues here. For reasons drowl_media/bundle_slideshow is not loaded, but its falsely defined twice, for bundle codument and bundle slideshow.

    Furthermore the media document bundle styles are never loaded, because we check for the slideshow bundle.

    function drowl_media_preprocess_media(array &$variables) {
      // Attach frontend libraries by bundle
      if(!empty($variables['elements']['#media'])){
        $attachments['#attached']['library'][] = 'drowl_media/global';
        $bundle = $variables['elements']['#media']->bundle();
        if($bundle == 'document'){
          $attachments['#attached']['library'][] = 'drowl_media/bundle_slideshow';
        }
        if($bundle == 'remote_video' || $bundle == 'video'){
          $attachments['#attached']['library'][] = 'drowl_media/bundle_video';
        }
        if($bundle == 'slideshow'){
          $attachments['#attached']['library'][] = 'drowl_media/bundle_slideshow';
        }
      }
    }
  • @anybody documents should be fixed, the drowl_media/bundle_slideshow library is still not loaded, while the bundle is correct.

    Ideas?

        if($bundle == 'slideshow'){
          $attachments['#attached']['library'][] = 'drowl_media/bundle_slideshow';
        }
  • Ouh, found it -_-

    Copy+paste issue, ALLE this libraries aren't loaded..

    $attachments was accidentally copied from:

    function drowl_media_page_attachments(array &$attachments) {
      $isAdminRoute = \Drupal::service('router.admin_context')->isAdminRoute();
      if ($isAdminRoute) {
        $attachments['#attached']['library'][] = 'drowl_media/admin';
      }
    }

    while it needs to be $variables here..

    function drowl_media_preprocess_media(array &$variables) {
      // Attach frontend libraries by bundle
      if(!empty($variables['elements']['#media'])){
        $variables['#attached']['library'][] = 'drowl_media/global';
        $bundle = $variables['elements']['#media']->bundle();
        if($bundle == 'document'){
          $variables['#attached']['library'][] = 'drowl_media/bundle_documents';
        }
        if($bundle == 'remote_video' || $bundle == 'video'){
          $variables['#attached']['library'][] = 'drowl_media/bundle_video';
        }
        if($bundle == 'slideshow'){
          $variables['#attached']['library'][] = 'drowl_media/bundle_slideshow';
        }
      }
    }
  • @anybody please review! We should create a new release now.

  • Status changed to Needs review over 1 year ago
  • Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
  • @anybody opened merge request.
  • Status changed to Needs work over 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

    @thomas.frobieter please review and resolve the comments. Did you already test it?
    Really dangerous bug... the IDE should have told, that the variable does not exist... mhm

  • Assigned to Anybody
  • Status changed to Needs review over 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica
  • Open on Drupal.org →
    Core: 10.0.7 + Environment: PHP 8.0 & MySQL 5.7
    last update over 1 year ago
    Waiting for branch to pass
    • Anybody committed f943a342 on 3.x
      Issue #3366945 by thomas.frobieter: Library drowl_media/bundle_slideshow...
  • Issue was unassigned.
  • Status changed to Fixed over 1 year ago
  • 🇩🇪Germany Anybody Porta Westfalica

    Merged! :)

  • Thx alot! Creating release..

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024