You are here

public function Facebook::renderEmbedCode in Video Embed Facebook 8

File

src/Plugin/video_embed_field/Provider/Facebook.php, line 18

Class

Facebook
Plugin annotation @VideoEmbedProvider( id = "facebook", title = @Translation("Facebook") )

Namespace

Drupal\video_embed_facebook\Plugin\video_embed_field\Provider

Code

public function renderEmbedCode($width, $height, $autoplay) {

  // @todo, consider using the JavaScript version, however iframes are less
  // impact to page load and also don't grant JS access to your website to
  // Facebook.
  return [
    '#type' => 'html_tag',
    '#tag' => 'iframe',
    '#attributes' => [
      'width' => $width,
      'height' => $height,
      'frameborder' => '0',
      'allowfullscreen' => 'allowfullscreen',
      'src' => sprintf('https://www.facebook.com/video/embed?video_id=%s', $this
        ->getVideoId(), $autoplay),
    ],
  ];
}