You are here

public function BlazyStylePluginBase::buildElement in Blazy 8

Same name and namespace in other branches
  1. 8.2 src/Dejavu/BlazyStylePluginBase.php \Drupal\blazy\Dejavu\BlazyStylePluginBase::buildElement()
  2. 7 src/Dejavu/BlazyStylePluginBase.php \Drupal\blazy\Dejavu\BlazyStylePluginBase::buildElement()

Returns an individual row/element content.

1 call to BlazyStylePluginBase::buildElement()
BlazyViewsTest::buildElements in tests/modules/blazy_test/src/Plugin/views/style/BlazyViewsTest.php
Returns blazy_test contents.

File

src/Dejavu/BlazyStylePluginBase.php, line 49

Class

BlazyStylePluginBase
A base for blazy views integration to have re-usable methods in one place.

Namespace

Drupal\blazy\Dejavu

Code

public function buildElement(array &$element, $row, $index) {
  $settings =& $element['settings'];
  $item_id = empty($settings['item_id']) ? 'box' : $settings['item_id'];

  // Add main image fields if so configured.
  if (!empty($settings['image'])) {

    // Supports individual grid/box image style either inline IMG, or CSS.
    $image = $this
      ->getImageRenderable($settings, $row, $index);
    $element['item'] = $this
      ->getImageItem($image);
    $element[$item_id] = empty($image['rendered']) ? [] : $image['rendered'];
  }

  // Add caption fields if so configured.
  $element['caption'] = $this
    ->getCaption($index, $settings);

  // Add layout field, may be a list field, or builtin layout options.
  if (!empty($settings['layout'])) {
    $this
      ->getLayout($settings, $index);
  }
}