You are here

class Instagram in Video Embed Instagram 8

Plugin annotation


@VideoEmbedProvider(
  id = "instagram",
  title = @Translation("Instagram")
)

Hierarchy

  • class \Drupal\video_embed_instagram\Plugin\video_embed_field\Provider\Instagram extends \Drupal\video_embed_field\ProviderPluginBase

Expanded class hierarchy of Instagram

1 file declares its use of Instagram
ProviderUrlParseTest.php in tests/src/Unit/ProviderUrlParseTest.php
Contains Drupal\Tests\video_embed_instagram\Unit\ProviderUrlParseTest.

File

src/Plugin/video_embed_field/Provider/Instagram.php, line 18
Contains \Drupal\video_embed_instagram\Plugin\video_embed_field\Provider\Instagram.

Namespace

Drupal\video_embed_instagram\Plugin\video_embed_field\Provider
View source
class Instagram extends ProviderPluginBase {

  /**
   * {@inheritdoc}
   */
  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',
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function getRemoteThumbnailUrl() {
    return sprintf('http://instagr.am/p/%s/media/?size=l', $this
      ->getVideoId());
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Members