class Facebook in Video 8
Same name and namespace in other branches
- 8.2 src/Plugin/video/Provider/Facebook.php \Drupal\video\Plugin\video\Provider\Facebook
Plugin annotation
@VideoEmbeddableProvider(
id = "facebook",
label = @Translation("Facebook"),
description = @Translation("Facebook Video Provider"),
regular_expressions = {
"@^https?://www\.facebook\.com/.*(/videos/(?<id>\d+))@i",
"@^https?://www\.facebook\.com/.*(video\.php\?v=(?<id>\d+))@i"
},
mimetype = "video/facebook",
stream_wrapper = "facebook"
)
Hierarchy
- class \Drupal\video\ProviderPluginBase implements ContainerFactoryPluginInterface, ProviderPluginInterface
- class \Drupal\video\Plugin\video\Provider\Facebook
Expanded class hierarchy of Facebook
1 string reference to 'Facebook'
- FacebookStream::getName in src/
StreamWrapper/ FacebookStream.php - Returns the name of the stream wrapper for use in the UI.
File
- src/
Plugin/ video/ Provider/ Facebook.php, line 21
Namespace
Drupal\video\Plugin\video\ProviderView source
class Facebook extends ProviderPluginBase {
/**
* {@inheritdoc}
*/
public function renderEmbedCode($settings) {
$file = $this
->getVideoFile();
$data = $this
->getVideoMetadata();
// @see https://developers.facebook.com/docs/plugins/embedded-video-player
return [
'#type' => 'html_tag',
'#tag' => 'div',
'0' => [
'#type' => 'html_tag',
'#tag' => 'script',
'#value' => 'window.fbAsyncInit = function() {
FB.init({
xfbml : true,
version : \'v2.3\'
});
}; (function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, \'script\', \'facebook-jssdk\'));',
],
'1' => [
'#type' => 'html_tag',
'#tag' => 'div',
'#attributes' => [
'class' => 'fb-video',
'data-href' => sprintf('https://www.facebook.com/video.php?v=%s', $data['id']),
'data-width' => $settings['width'],
'data-autoplay' => $settings['autoplay'] ? 1 : 0,
],
],
];
}
/**
* {@inheritdoc}
*/
public function getRemoteThumbnailUrl() {
$data = $this
->getVideoMetadata();
return 'https://graph.facebook.com/' . $data['id'] . '/picture';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Facebook:: |
public | function |
Get the URL of the remote thumbnail. Overrides ProviderPluginInterface:: |
|
Facebook:: |
public | function |
Render embed code. Overrides ProviderPluginInterface:: |
|
ProviderPluginBase:: |
protected | property | File object to handle | |
ProviderPluginBase:: |
protected | property | An http client. | |
ProviderPluginBase:: |
protected | property | Additional metadata for the embedded video object | |
ProviderPluginBase:: |
protected | property | Additional settings for the video widget | |
ProviderPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
ProviderPluginBase:: |
protected | function | Download the remote thumbnail to the local file system. | |
ProviderPluginBase:: |
public | function | Get the URL to the local thumbnail. | |
ProviderPluginBase:: |
protected | function | Determines the URI for a video field. | |
ProviderPluginBase:: |
protected | function | Get the ID of the video. | |
ProviderPluginBase:: |
protected | function | Get the input which caused this plugin to be selected. | |
ProviderPluginBase:: |
protected | function | Get the input which caused this plugin to be selected. | |
ProviderPluginBase:: |
public | function | ||
ProviderPluginBase:: |
public | function | Create a plugin with the given input. |