You are here

public function Dailymotion::renderEmbedCode in Video 8

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

Class

Dailymotion
Plugin annotation @VideoEmbeddableProvider( id = "dailymotion", label = @Translation("Dailymotion"), description = @Translation("Dailymotion Video Provider"), regular_expressions = { "@dailymotion\.com/video/(?<id>[^/_]+)_@i", }, …

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('//www.dailymotion.com/embed/video/%s?autoPlay=$d', $data['id'], $settings['autoplay']),
    ],
  ];
}