You are here

public function BlazyStylePluginTrait::getImageItem in Blazy 7

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

Get the image item to work with out of this formatter.

Unlike D8, Views may render/ flatten images earlier.

3 calls to BlazyStylePluginTrait::getImageItem()
BlazyStylePluginBase::buildElement in src/Dejavu/BlazyStylePluginBase.php
Returns an individual row/element content.
BlazyStylePluginTrait::getImageRenderable in src/Dejavu/BlazyStylePluginTrait.php
Returns the modified renderable image_formatter to support lazyload.
BlazyStylePluginTrait::isImageRenderable in src/Dejavu/BlazyStylePluginTrait.php
Checks if we can work with this formatter, otherwise no go if flattened.

File

src/Dejavu/BlazyStylePluginTrait.php, line 92

Class

BlazyStylePluginTrait
A Trait common for optional views style plugins for slick, etc.

Namespace

Drupal\blazy\Dejavu

Code

public function getImageItem($image) {
  $item = [];

  // Image formatter.
  if (isset($image['raw'])) {
    $item = empty($image['rendered']['#item']) ? [] : (object) $image['rendered']['#item'];

    // Blazy formatter.
    if (isset($image['rendered']['#build'])) {
      $item = (object) $image['rendered']['#build']['item'];
    }
  }
  return $item;
}