PHP YouTube Embed Function
PHP kôd:
function youtube($id, $type = "standard", $w = 600, $h = 385){
switch($type){
case "standard":
return('<object width="'.$w.'" height="'.$h.'"><param name="movie" value="http://www.youtube.com/v/'.$id.'?fs=1&hl=en_US&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/'.$id.'?fs=1&hl=en_US&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="'.$w.'" height="'.$h.'"></embed></object>');
break;
case "valid":
return('<object type="application/x-shockwave-flash" data="http://www.youtube.com/v/'.$id.'?fs=1&hl=en_US&rel=0" width="'.$w.'px" height='.$h.'px">
<param name="movie" value="http://www.youtube.com/v/'.$id.'?fs=1&hl=en_US&rel=0" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="align" value="TC" />
<param name="scale" value="exactfit" />
</object>');
break;
case "iframe":
return('<iframe class="youtube-player" type="text/html" width="'.$w.'" height="'.$h.'" src="http://www.youtube.com/embed/'.$id.'"></iframe>');
break;
}
}
Source:
http://webarto.com/57/php-youtube-embed-function
Demo:
http://webarto.com/demo.php?demo=56
Code:
http://sorskod.com/d30PpLJw