You are here

public function BlazyManager::getBlazy in Blazy 7

Same name and namespace in other branches
  1. 8.2 src/BlazyManager.php \Drupal\blazy\BlazyManager::getBlazy()
  2. 8 src/BlazyManager.php \Drupal\blazy\BlazyManager::getBlazy()

Returns the enforced content, or image using theme_blazy().

The image_style property is not directly used by theme_blazy() but for a quick reference such as from a Views style plugin rather than deep drill. Will be removed if we figure out a better way, or no longer useful.

Parameters

array $build: The array containing:

  • item: The image / file entity item object converted from array.
  • settings: An array of settings to instruct Blazy what to do.
  • captions: Optional captions for both inline, or lightbox as per name.

Return value

array The alterable and renderable array of enforced content, or theme_blazy().

File

src/BlazyManager.php, line 68

Class

BlazyManager
Implements a public facing blazy manager.

Namespace

Drupal\blazy

Code

public function getBlazy(array $build = []) {
  foreach (BlazyDefault::themeProperties() as $key) {
    $build[$key] = isset($build[$key]) ? $build[$key] : [];
  }
  $settings =& $build['settings'];
  $settings += BlazyDefault::itemSettings();
  $item = $build['item'];
  $settings['uri'] = $settings['uri'] ?: ($item && isset($item->uri) ? $item->uri : '');
  $content = [
    '#theme' => 'blazy',
    '#image_style' => $settings['image_style'],
    '#item' => $item,
    '#build' => $build,
    '#pre_render' => [
      'blazy_pre_render',
    ],
  ];
  drupal_alter('blazy', $content, $settings);
  return empty($settings['uri']) ? [] : $content;
}