You are here

public function BlazyVideoFormatter::buildElements in Blazy 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/BlazyVideoFormatter.php \Drupal\blazy\Plugin\Field\FieldFormatter\BlazyVideoFormatter::buildElements()

Build the blazy elements.

1 call to BlazyVideoFormatter::buildElements()
BlazyVideoFormatter::viewElements in src/Plugin/Field/FieldFormatter/BlazyVideoFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/BlazyVideoFormatter.php, line 90

Class

BlazyVideoFormatter
Plugin implementation of the 'Blazy Video' to get VEF videos.

Namespace

Drupal\blazy\Plugin\Field\FieldFormatter

Code

public function buildElements(array &$build, $items) {
  $settings = $build['settings'];
  foreach ($items as $delta => $item) {
    $settings['input_url'] = trim(strip_tags($item->value));
    $settings['delta'] = $delta;
    if (empty($settings['input_url'])) {
      continue;
    }
    $this
      ->buildVideo($settings);
    $box = [
      'item' => $item,
      'settings' => $settings,
    ];

    // Image with responsive image, lazyLoad, and lightbox supports.
    $build[$delta] = $this->blazyManager
      ->getImage($box);
    unset($box);
  }
}