You are here

public static function BlazyTestAlter::preRender in Blazy 8.2

The #pre_render callback: Sets lightbox image URL.

File

tests/modules/blazy_test/src/BlazyTestAlter.php, line 18

Class

BlazyTestAlter
Provides a render callback to sets blazy_test related URL attributes.

Namespace

Drupal\blazy_test

Code

public static function preRender($image) {
  $settings = isset($image['#settings']) ? $image['#settings'] : [];

  // Video's HREF points to external site, adds URL to local image.
  if (!empty($settings['box_url']) && !empty($settings['embed_url'])) {
    $image['#url_attributes']['data-box-url'] = $settings['box_url'];
  }
  return $image;
}