You are here

public function ProviderPluginBase::renderThumbnail in Video 8

Same name and namespace in other branches
  1. 8.2 src/ProviderPluginBase.php \Drupal\video\ProviderPluginBase::renderThumbnail()

File

src/ProviderPluginBase.php, line 101

Class

ProviderPluginBase
A base for the provider plugins.

Namespace

Drupal\video

Code

public function renderThumbnail($image_style, $link_url) {
  $this
    ->downloadThumbnail();
  $output = [
    '#theme' => 'image',
    '#uri' => !empty($image_style) ? ImageStyle::load($image_style)
      ->buildUrl($this
      ->getLocalThumbnailUri()) : $this
      ->getLocalThumbnailUri(),
  ];
  if ($link_url) {
    $output = [
      '#type' => 'link',
      '#title' => $output,
      '#url' => $link_url,
    ];
  }
  return $output;
}