You are here

public function Vine::renderEmbedCode in Video 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/video/Provider/Vine.php \Drupal\video\Plugin\video\Provider\Vine::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/Vine.php, line 23

Class

Vine
Plugin annotation @VideoEmbeddableProvider( id = "vine", label = @Translation("Vine"), description = @Translation("Vine Video Provider"), regular_expressions = { "@(?<=vine.co/v/)(?<id>[0-9A-Za-z]+)@i", }, mimetype =…

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://vine.co/v/%s/embed/simple?autoPlay=%d', $data['id'], $settings['autoplay']),
    ],
  ];
}