Facebook.php in Video Embed Facebook 8
File
src/Plugin/video_embed_field/Provider/Facebook.php
View source
<?php
namespace Drupal\video_embed_facebook\Plugin\video_embed_field\Provider;
use Drupal\video_embed_field\ProviderPluginBase;
class Facebook extends ProviderPluginBase {
public function renderEmbedCode($width, $height, $autoplay) {
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),
],
];
}
public function getRemoteThumbnailUrl() {
return sprintf('https://graph.facebook.com/%d/picture', $this
->getVideoId());
}
public static function getIdFromInput($input) {
preg_match('/^https?:\\/\\/(www\\.)?facebook.com\\/([\\w\\-\\.]*\\/videos\\/|video\\.php\\?v\\=)(?<id>[0-9]*)\\/?$/', $input, $matches);
return isset($matches['id']) ? $matches['id'] : FALSE;
}
}
Classes
Name |
Description |
Facebook |
Plugin annotation
@VideoEmbedProvider(
id = "facebook",
title = @Translation("Facebook")
) |