You are here

public function BlazyFormatter::extractFirstItem in Blazy 7

Same name and namespace in other branches
  1. 8.2 src/BlazyFormatter.php \Drupal\blazy\BlazyFormatter::extractFirstItem()
1 call to BlazyFormatter::extractFirstItem()
BlazyFormatter::preBuildElements in src/BlazyFormatter.php

File

src/BlazyFormatter.php, line 140

Class

BlazyFormatter
Implements BlazyFormatterInterface.

Namespace

Drupal\blazy

Code

public function extractFirstItem(array &$settings, $item, $entity = NULL) {
  if ($settings['field_type'] == 'image') {
    $this->firstItem = (object) $item;
  }
  elseif ($settings['field_type'] == 'file' && ($image = BlazyMedia::imageItem($item))) {
    $this->firstItem = $image;
  }

  // The first image dimensions to differ from individual item dimensions.
  $item = $this->firstItem;
  Blazy::imageDimensions($settings, $item, TRUE);

  // @todo remove first_uri for _uri for consistency.
  $settings['_uri'] = $settings['first_uri'] = $item && isset($item->uri) ? $item->uri : '';
}