You are here

protected function BlazyManager::getSettings in Blazy 8.2

Prepares Blazy settings.

2 calls to BlazyManager::getSettings()
BlazyManager::build in src/BlazyManager.php
Returns the contents using theme_field(), or theme_item_list().
BlazyManager::preRenderBuild in src/BlazyManager.php
Builds the Blazy outputs as a structured array ready for ::renderer().

File

src/BlazyManager.php, line 517

Class

BlazyManager
Implements a public facing blazy manager.

Namespace

Drupal\blazy

Code

protected function getSettings(array &$build) {
  $settings = isset($build['settings']) ? $build['settings'] : [];
  $settings += BlazyDefault::htmlSettings();

  // Supports Blazy multi-breakpoint images if provided, updates $settings.
  // Cases: Blazy within Views gallery, or references without direct image.
  if (!empty($settings['first_image']) && !empty($settings['check_blazy'])) {

    // Views may flatten out the array, bail out.
    // What we do here is extract the formatter settings from the first found
    // image and pass its settings to this container so that Blazy Grid which
    // lacks of settings may know if it should load/ display a lightbox, etc.
    // Lightbox should work without `Use field template` checked.
    if (is_array($settings['first_image'])) {
      $this
        ->isBlazy($settings, $settings['first_image']);
    }
  }
  return $settings;
}