You are here

class Vine in Video 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/video/Provider/Vine.php \Drupal\video\Plugin\video\Provider\Vine

Plugin annotation


@VideoEmbeddableProvider(
  id = "vine",
  label = @Translation("Vine"),
  description = @Translation("Vine Video Provider"),
  regular_expressions = {
    "@(?<=vine.co/v/)(?<id>[0-9A-Za-z]+)@i",
  },
  mimetype = "video/vine",
  stream_wrapper = "vine"
)

Hierarchy

Expanded class hierarchy of Vine

1 string reference to 'Vine'
VineStream::getName in src/StreamWrapper/VineStream.php
Returns the name of the stream wrapper for use in the UI.

File

src/Plugin/video/Provider/Vine.php, line 19

Namespace

Drupal\video\Plugin\video\Provider
View source
class Vine extends ProviderPluginBase {

  /**
   * {@inheritdoc}
   */
  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('https://vine.co/v/%s/embed/simple?autoPlay=%d', $data['id'], $settings['autoplay']),
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getRemoteThumbnailUrl() {
    $data = $this
      ->getVideoMetadata();
    $id = $data['id'];
    $vine = file_get_contents("http://vine.co/v/{$id}");
    preg_match('/property="og:image" content="(.*?)"/', $vine, $matches);
    return $matches[1] ? $matches[1] : false;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ProviderPluginBase::$file protected property File object to handle
ProviderPluginBase::$httpClient protected property An http client.
ProviderPluginBase::$metadata protected property Additional metadata for the embedded video object
ProviderPluginBase::$settings protected property Additional settings for the video widget
ProviderPluginBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
ProviderPluginBase::downloadThumbnail protected function Download the remote thumbnail to the local file system.
ProviderPluginBase::getLocalThumbnailUri public function Get the URL to the local thumbnail.
ProviderPluginBase::getUploadLocation protected function Determines the URI for a video field.
ProviderPluginBase::getVideoFile protected function Get the ID of the video.
ProviderPluginBase::getVideoMetadata protected function Get the input which caused this plugin to be selected.
ProviderPluginBase::getVideoSettings protected function Get the input which caused this plugin to be selected.
ProviderPluginBase::renderThumbnail public function
ProviderPluginBase::__construct public function Create a plugin with the given input.
Vine::getRemoteThumbnailUrl public function Get the URL of the remote thumbnail. Overrides ProviderPluginInterface::getRemoteThumbnailUrl
Vine::renderEmbedCode public function Render embed code. Overrides ProviderPluginInterface::renderEmbedCode