You are here

public function SlickFormatter::getThumbnail in Slick Carousel 8

Same name and namespace in other branches
  1. 8.2 src/SlickFormatter.php \Drupal\slick\SlickFormatter::getThumbnail()
  2. 7.3 src/SlickFormatter.php \Drupal\slick\SlickFormatter::getThumbnail()

Gets the thumbnail image using theme_image_style().

Parameters

array $settings: The array containing: thumbnail_style, etc.

object $item: The \Drupal\image\Plugin\Field\FieldType\ImageItem object.

Return value

array The renderable array of thumbnail image.

File

src/SlickFormatter.php, line 71

Class

SlickFormatter
Implements SlickFormatterInterface.

Namespace

Drupal\slick

Code

public function getThumbnail(array $settings = [], $item = NULL) {
  $thumbnail = [];
  $thumbnail_alt = '';
  if ($item instanceof ImageItem) {
    $thumbnail_alt = $item
      ->getValue()['alt'];
  }
  if (!empty($settings['uri'])) {
    $thumbnail = [
      '#theme' => 'image_style',
      '#style_name' => isset($settings['thumbnail_style']) ? $settings['thumbnail_style'] : 'thumbnail',
      '#uri' => $settings['uri'],
      '#item' => $item,
      '#alt' => $thumbnail_alt,
    ];
  }
  return $thumbnail;
}