Fixing link when using the youtube shortener when adding a link in a LP see BT#3490

skala
Julio Montoya 14 years ago
parent bd69db7b9c
commit 397309af58
  1. 24
      main/inc/lib/link.lib.php

@ -946,7 +946,8 @@ function import_csvfile() {
* @version 1.0
*/
function is_youtube_link($url) {
return strrpos($url, "youtube");
$is_youtube_link = strrpos($url, "youtube") || strrpos($url, "youtu.be");
return $is_youtube_link;
}
function get_youtube_video_id($url) {
@ -956,14 +957,27 @@ function get_youtube_video_id($url) {
// The ID string starts after "v=", which is usually right after
// "youtube.com/watch?" in the URL
$pos = strpos($url, "v=");
//try the youtube URL shortener
//http://youtu.be/gD0qDugOs7k
if ($pos === false) {
$pos = strpos($url, "youtu.be");
if ($pos == false) {
return '';
} else {
$path_info = pathinfo($url);
return $path_info['basename'];
}
}
// If still FALSE, URL doesn't have a vid ID
if ($pos === false) {
return '';
}
}
// Offset the start location to match the beginning of the ID string
$pos += 2;
// Get the ID string and return it
$ytvID = substr($url, $pos, $len);
return $ytvID;
}
$id = substr($url, $pos, $len);
return $id;
}

Loading…
Cancel
Save