Okay, more details on my intentions, so I can clarify issue better:
The url that has thumbnail images linked to its videos that are located like this:
http://cdn1.image.webiste.webcdn.com/5/6/7/160x120/8.jpg
7 in the path, is the actual video id with respective video I am interested in.
5 and 6 in the path, are dynamic too, and also change with video I am interested in.
If I use the above link, I can see the video thumbnail in browser.
If I use this code, I can take that video thumbnail, and for that particular video (referencing path 5 and 6), and it comes to my website:
[php]thumbnail = ‘http://cdn1.image.website.webcdn.com/5/7/’.$url_id.’/160x120/8.jpg’;
[/php]
BUT, if I use this code now, with paths 5 or 6 having the variables too, it fails:
[php]]$thumbnail = ‘http://cdn1.image.website.webcdn.com/’.$id_url.’/’.$url_name.’/’.$url_id.’/160x120/8.jpg’;[/php]
My code, what is giving me problems is this:
[php]
function video_embed_website_handle_thumbnail($url) {
$name = _video_embed_website_get_video_name($url);
$id = _video_embed_website_get_video_id($url);
$url_id = _video_embed_website_get_video_url_id($url);
$url_name = _video_embed_website_get_video_url_name($url);
$id_url = _video_embed_website_get_video_id_url($url);
$thumbnail = ‘http://cdn1.image.website.webcdn.com/’.$id_url.’/’.$url_name.’/’.$url_id.’/160x120/8.jpg’;
return array(
‘name’ => $name,
‘id’ => $id,
‘url_id’ => $url_id,
‘url_name’ => $url_name,
‘id_url’ => $id_url,
‘url’ => $thumbnail,
);
}
function _video_embed_website_split($s, $str) {
$ret = array();
$tmp = ‘’;
$size = strlen($str);
for ($i = 0; $i < $size; $i++) {
$char = substr($str, $i, 1);
if ($char == $s) {
$ret[] = $tmp;
$tmp = ‘’;
}
else {
$tmp .= $char;
}
}
if ($tmp) {
$ret[] = $tmp;
}
return $ret;
}
function _video_embed_website_get_video_id_url($url) {
$matches = array();
$matches = _video_embed_website_split("/", $url);
$index = count($matches) - 5;
if ($matches[$index]) {
return $matches[$index];
}
return FALSE;
}
function _video_embed_website_get_video_url_name($url) {
$matches = array();
$matches = _video_embed_website_split("/", $url);
$index = count($matches) - 4;
if ($matches[$index]) {
return $matches[$index];
}
return FALSE;
}
function _video_embed_website_get_video_url_id($url) {
$matches = array();
$matches = _video_embed_website_split("/", $url);
$index = count($matches) - 3;
if ($matches[$index]) {
return $matches[$index];
}
return FALSE;
}
function _video_embed_website_get_video_id($url) {
$matches = array();
$matches = _video_embed_website_split("/", $url);
$index = count($matches) - 2;
if ($matches[$index]) {
return $matches[$index];
}
return FALSE;
}
function _video_embed_website_get_video_name($url) {
$matches = array();
$matches = _video_embed_website_split("/",$url);
if (end($matches)) {
return end($matches);
}
return FALSE;
}
[/php]
Thanks again!