You are here

public function BlazyStyleBaseTrait::getFieldRenderable in Blazy 8

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

Returns the renderable array of field containing rendered and raw data.

1 call to BlazyStyleBaseTrait::getFieldRenderable()
BlazyStyleBaseTrait::getFirstImage in src/Dejavu/BlazyStyleBaseTrait.php
Returns the first Blazy formatter found.

File

src/Dejavu/BlazyStyleBaseTrait.php, line 125

Class

BlazyStyleBaseTrait
A Trait common for optional views style plugins.

Namespace

Drupal\blazy\Dejavu

Code

public function getFieldRenderable($row, $index, $field_name = '', $multiple = FALSE) {
  if (empty($field_name)) {
    return FALSE;
  }

  // Be sure to not check "Use field template" under "Style settings" to have
  // renderable array to work with, otherwise flattened string!
  $result = isset($this->view->field[$field_name]) ? $this->view->field[$field_name]
    ->getItems($row) : [];
  return empty($result) ? [] : ($multiple ? $result : $result[0]);
}