You are here

function slick_get_media_id in Slick Carousel 7.2

Gets Youtube/ Vimeo video ID from URL, thanks to Kus from s.o.

1 call to slick_get_media_id()
slick_format_media in includes/slick.media.inc
Formats image/media file data.

File

includes/slick.extras.inc, line 50
Contains optional functions called by frontend Media, or Field collection.

Code

function slick_get_media_id($url) {
  $parts = parse_url($url);
  if (isset($parts['query'])) {
    parse_str($parts['query'], $qs);
    if (isset($qs['v'])) {
      return $qs['v'];
    }
    elseif (isset($qs['vi'])) {
      return $qs['vi'];
    }
  }
  if (isset($parts['path'])) {
    $path = explode('/', trim($parts['path'], '/'));
    return $path[count($path) - 1];
  }
  return FALSE;
}