You are here

public function Vimeo::renderEmbedCode in Video 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/video/Provider/Vimeo.php \Drupal\video\Plugin\video\Provider\Vimeo::renderEmbedCode()

Render embed code.

Parameters

string $settings: The settings of the video player.

Return value

mixed A renderable array of the embed code.

Overrides ProviderPluginInterface::renderEmbedCode

File

src/Plugin/video/Provider/Vimeo.php, line 25

Class

Vimeo
Plugin annotation @VideoEmbeddableProvider( id = "vimeo", label = @Translation("Vimeo"), description = @Translation("Vimeo Video Provider"), regular_expressions = { …

Namespace

Drupal\video\Plugin\video\Provider

Code

public function renderEmbedCode($settings) {
  $file = $this
    ->getVideoFile();
  $data = $this
    ->getVideoMetadata();
  return [
    '#type' => 'html_tag',
    '#tag' => 'iframe',
    '#attributes' => [
      'width' => $settings['width'],
      'height' => $settings['height'],
      'frameborder' => '0',
      'allowfullscreen' => 'allowfullscreen',
      'src' => sprintf('https://player.vimeo.com/video/%s?autoplay=%d', $data['id'], $settings['autoplay']),
    ],
  ];
}