Instagram.php in Video Embed Instagram 8
File
src/Plugin/video_embed_field/Provider/Instagram.php
View source
<?php
namespace Drupal\video_embed_instagram\Plugin\video_embed_field\Provider;
use Drupal\video_embed_field\ProviderPluginBase;
class Instagram extends ProviderPluginBase {
public function renderEmbedCode($width, $height, $autoplay) {
return [
'#type' => 'video_embed_iframe',
'#provider' => 'instagram',
'#url' => sprintf('http://instagram.com/p/%s/embed', $this
->getVideoId()),
'#attributes' => [
'width' => $width,
'height' => $height,
'frameborder' => '0',
'allowfullscreen' => 'allowfullscreen',
],
];
}
public function getRemoteThumbnailUrl() {
return sprintf('http://instagr.am/p/%s/media/?size=l', $this
->getVideoId());
}
public static function getIdFromInput($input) {
preg_match('/^https?:\\/\\/(www)?\\.instagram\\.com\\/p\\/(?<id>[a-zA-Z0-9]*)\\/?/', $input, $matches);
return isset($matches['id']) ? $matches['id'] : FALSE;
}
}
Classes
Name |
Description |
Instagram |
Plugin annotation
@VideoEmbedProvider(
id = "instagram",
title = @Translation("Instagram")
) |