You are here

protected function Media::prepareOverlay in GridStack 8.2

Returns the media overlay.

1 call to Media::prepareOverlay()
Media::prepareMedia in src/Plugin/gridstack/stylizer/Media.php
Returns the formatted media as Blazy output.

File

src/Plugin/gridstack/stylizer/Media.php, line 132

Class

Media
Provides the media styles for front-end.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

protected function prepareOverlay(array &$data, array $settings) {
  $bg = $this
    ->getBackgroundColor($settings, FALSE);
  $use_overlay = $this
    ->getStyle('overlay', $settings);

  // Always output for admin for live preview to work.
  // @todo use ::pseudo selector for front-end.
  $overlay = [
    '#theme' => 'container',
    '#attributes' => [
      'class' => [
        'media__overlay',
      ],
    ],
  ];

  // Only inline CSS at admin pages, front-end should be cleaner.
  if ($use_overlay && $bg && !empty($settings['_ipe'])) {
    $overlay['#attributes']['style'] = $bg;
  }

  // @todo post blazy 2.1
  // @todo $build['overlay']['gridstack'] = $overlay;
  // @todo $build['overlay']['gridstack']['#weight'] = 100;
  $data['icon']['gridstack_overlay'] = $overlay;
  $data['icon']['gridstack_overlay']['#weight'] = 100;

  // Remove from front-end if not configured so.
  if (empty($settings['_ipe'])) {
    if ($use_overlay && empty($bg)) {
      unset($data['icon']['gridstack_overlay']);
    }
  }
}