You are here

function video_embed_dailymotion_handle_video in Video Embed Dailymotion 7

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

Parameters

string $url: the full video url

array $settings: an associative array of this handlers settings, from the settings form

Return value

string the embed code for the video

1 string reference to 'video_embed_dailymotion_handle_video'
video_embed_dailymotion_video_embed_handler_info in ./video_embed_dailymotion.module
Implements hook_video_embed_handler_info().

File

./video_embed_dailymotion.module, line 85
Add a handler for dailymotion videos to Video Embed Field with this module you can add videos from dailymotion.com

Code

function video_embed_dailymotion_handle_video($url, $settings) {
  $id = _video_embed_dailymotion_get_video_id($url);
  if ($id) {
    $embed = '<object width="!width" height="!height">
    <param name="movie" value="http://www.dailymotion.com/swf/video/!id?autoPlay=!autoplay"></param>
    <param name="allowFullScreen" value="!fullscreen"></param>
    <param name="allowScriptAccess" value="always"></param>
    <embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/!id?autoPlay=!autoplay"' . 'width="!width" height="!height" allowfullscreen="!fullscreen" allowscriptaccess="always"></embed>
    </object>';
    $embed = format_string($embed, array(
      '!id' => $id,
      '!fullscreen' => $settings['allowfullscreen'] ? 'true' : 'false',
      '!autoplay' => $settings['allowautoplay'] ? 'true' : 'false',
      '!width' => $settings['width'],
      '!height' => $settings['height'],
    ));
    $video = array(
      '#markup' => $embed,
    );
    return $video;
  }

  // Return an empty string if there is no id, so we don't have broken embeds.
  return '';
}