You are here

public function BlazyStyleBaseTrait::getFirstImage in Blazy 7

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

Returns the first Blazy formatter found.

1 call to BlazyStyleBaseTrait::getFirstImage()
BlazyViews::render in src/Plugin/views/style/BlazyViews.php
Overrides StylePluginBase::render().

File

src/Dejavu/BlazyStyleBaseTrait.php, line 96

Class

BlazyStyleBaseTrait
A Trait common for optional views style plugins.

Namespace

Drupal\blazy\Dejavu

Code

public function getFirstImage($row) {
  if (!isset($this->firstImage)) {
    $rendered = [];
    if ($row) {
      foreach ($row as $item) {
        if (is_array($item) && isset($item[0]['rendered']) && isset($item[0]['rendered']['#build'])) {
          $rendered = $item[0]['rendered']['#build'];
          break;
        }
      }
    }
    $this->firstImage = $rendered;
  }
  return $this->firstImage;
}