Did you maybe put a $ at the front of your function name?
Dollar sign?? Maybe i'm wrong, but if i do this the function becomes a variable...
However, here's my function:
function $embedVideo($video,$giro,$size) {
if (strpos($video, "#") !== FALSE) {
$cut = explode("#", $video);
$video = $cut[0];
}
if( $size == "small") {
$img_set = "&w=130&h=70&zc=1&fltr[]=wmi|[(base_url)]/assets/templates/luigicinque/img/play_wm.png|68x38|66|50|50|0";
$giro = 0;
}
else {
$img_set = "&w=270&h=150&zc=1&fltr[]=wmi|[(base_url)]/assets/templates/luigicinque/img/play_wm.png|135x75|66|85|85|0";
}
$rel = "rel=\"shadowbox;width=640;height=385\"";
if (is_int($giro/2) == true){
$class = "mrg";
}
else { $class = ""; }
$video = trim($video);
if (strpos($video, "youtube") !== FALSE) {
$split = explode("&",$video);
$split2 = explode("=",$split[0]);
$v_id = $split2[1];
$img = "[(base_url)]image.php?src=http://img.youtube.com/vi/".$v_id."/0.jpg";
echo '<a href="http://www.youtube.com/embed/'.$v_id.'?rel=0&autoplay=1" '.$rel.'><img src="'.$img.$img_set.'" class="gray '.$class.'"></a>'."\n";
}
if (strpos($video, "vimeo") !== FALSE) {
$split = explode("vimeo.com/",$video);
$v_id = $split[1];
$json = @json_decode(file_get_contents('http://vimeo.com/api/oembed.json?url=http://vimeo.com/'.$v_id));
$thumb = $json->thumbnail_url;
$img = "[(base_url)]image.php?src=".$thumb;
echo '<a href="http://player.vimeo.com/video/'.$v_id.'?title=0&byline=0&portrait=0&autoplay=1" '.$rel.'><img src="'.$img.$img_set.'" class="gray '.$class.'"></a>'."\n";
}
if (strpos($video, "dailymotion") !== FALSE) {
$split = explode("video/",$video);
$v_id = $split[1];
$split = explode("_",$v_id);
$v_id = $split[0];
$img = "[(base_url)]image.php?src=http://www.dailymotion.com/thumbnail/video/".$v_id;
echo '<a href="http://www.dailymotion.com/embed/video/'.$v_id.'?autoPlay=1" '.$rel.'><img src="'.$img.$img_set.'" class="gray '.$class.'"></a>'."\n";
}
}
As you may have guessed, is a function to embed video using the URL... I'm thinking that echoing directly the results is not the right way... Maybe is better using return.. what do you think about it?
thanks
EDIT: I don't know why but when i post my code, an
<a> tag is automatically inserted before all urls that starts whit
http:// :
$img = "[(base_url)]image.php?src=<a href="http://img.youtube.com/vi/".$v_id."/0.jpg";" target="_blank" rel="nofollow">http://img.youtube.com/vi/".$v_id."/0.jpg";</a>
[ed. note: dscvr last edited this post 14 years, 9 months ago.]