You are here

public function ProviderPluginBase::renderThumbnail in Video Embed Field 8.2

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

Render a thumbnail.

Parameters

string $image_style: The quality of the thumbnail to render.

string $link_url: Where the thumbnail should be linked to.

Return value

array A renderable array of a thumbnail.

Overrides ProviderPluginInterface::renderThumbnail

File

src/ProviderPluginBase.php, line 117

Class

ProviderPluginBase
A base for the provider plugins.

Namespace

Drupal\video_embed_field

Code

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