You are here

public function BlazyViewsFieldFile::render in Blazy 7

Same name and namespace in other branches
  1. 8.2 src/Plugin/views/field/BlazyViewsFieldFile.php \Drupal\blazy\Plugin\views\field\BlazyViewsFieldFile::render()
  2. 8 src/Plugin/views/field/BlazyViewsFieldFile.php \Drupal\blazy\Plugin\views\field\BlazyViewsFieldFile::render()

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides BlazyViewsFieldPluginBase::render

File

src/Plugin/views/field/BlazyViewsFieldFile.php, line 15

Class

BlazyViewsFieldFile
Defines a custom field that renders a preview of a file.

Namespace

Drupal\blazy\Plugin\views\field

Code

public function render($values) {

  /** @var \Drupal\file\Entity\File $entity */
  $fid = $values->fid;
  $entity = file_load($fid);
  $settings = $this
    ->mergedViewsSettings();
  $settings['delta'] = $this->view->row_index;
  $settings['entity_type_id'] = 'file';
  $settings['uri'] = $entity->uri;
  $data = $this
    ->getImageItem($entity);
  $data['settings'] = isset($data['settings']) ? array_merge($settings, $data['settings']) : $settings;

  // Pass results to \Drupal\blazy\BlazyEntity.
  return $this
    ->blazyEntity()
    ->build($data, $entity);
}