You are here

function video_embed_instagram_handle_video in Video Embed Instagram 7

This is the video handler (the 'function' key from handler_info).

Function handles url and returns embed video html code.

Parameters

string $url: This is string witch user input into video field.

array $settings: Settings which were defined by admin.

Return value

mixed Return rendered html code or empty string if fails to get id from url.

1 string reference to 'video_embed_instagram_handle_video'
video_embed_instagram_video_embed_handler_info in ./video_embed_instagram.module
Implements hook_video_embed_handler_info().

File

./video_embed_instagram.module, line 101
Add a handler for instagram videos to Video Embed Field.

Code

function video_embed_instagram_handle_video($url, array $settings) {
  $output = '';
  $instagram_video_id = _video_embed_instagram_get_video_id($url);
  if ($instagram_video_id) {

    // Embed code.
    $embed = theme('video_embed_instagram', array(
      'url' => '//instagram.com/p/' . $instagram_video_id . '/embed/',
      'width' => $settings['width'],
      'height' => $settings['height'],
    ));

    // Return a render array.
    $video = array(
      '#markup' => $embed,
    );
    $output = $video;
  }
  else {
    drupal_set_message(t('Error with getting id of the video.'), 'error');
  }

  // Just return an empty string if there is no id,
  // so we don't have broken embeds showing up.
  return $output;
}