You are here

function video_embed_field_handle_vimeo in Video Embed Field 7

Same name and namespace in other branches
  1. 7.2 video_embed_field.handlers.inc \video_embed_field_handle_vimeo()

handler for vimeo videos Height and width need to be configurable or something I think

1 string reference to 'video_embed_field_handle_vimeo'
video_embed_field_video_embed_handler_info in ./video_embed_field.module
Implementation of hook_video_embed_handler_info

File

./video_embed_field.module, line 566

Code

function video_embed_field_handle_vimeo($url, $settings, $type = 'video', $image_size = 'small') {
  $pos = strripos($url, '/');
  if ($pos === FALSE) {

    //we can't figure out the url - just return the url as a link
    return l($url, $url);
  }
  else {
    $pos += 1;
    $id = substr($url, $pos);
  }
  if ($type == 'image') {
    $return = file_get_contents('http://vimeo.com/api/v2/video/' . $id . '.php');
    $return = unserialize($return);
    $video = current($return);

    // contains also thumbnail_medium, may want to check it
    if ($image_size == 'large') {
      $image_url = $video['thumbnail_large'];
    }
    else {
      if ($image_size == 'medium') {
        $image_url = $video['thumbnail_medium'];
      }
      else {
        $image_url = $video['thumbnail_small'];
      }
    }
    return '<img src="' . $image_url . '" />';
  }
  else {

    //get configuration options
    $teaser = $type == 'teaser';
    $height = $teaser ? $settings['teaser_height'] : $settings['height'];
    $width = $teaser ? $settings['teaser_width'] : $settings['width'];
    $color = $settings['color'];
    $autoplay = $settings['autoplay'];
    $template_start = '<iframe src="http://player.vimeo.com/video/';
    $template_end = '?portrait=0&amp;color=' . $color . '&amp;autoplay=' . $autoplay . '" frameborder="0" height="' . $height . '" width="' . $width . '"></iframe>';
    return $template_start . $id . $template_end;
  }
}