You are here

public function SlickFormatter::getThumbnail in Slick Carousel 8.2

Same name and namespace in other branches
  1. 8 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.

Overrides SlickFormatterInterface::getThumbnail

File

src/SlickFormatter.php, line 66

Class

SlickFormatter
Provides Slick field formatters utilities.

Namespace

Drupal\slick

Code

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