Hi all,
i am making a bbcode for youtube videos.User can post a video as bbcode eg like [youtube]http://www.youtube.com/watch?v=ihK2pPcDSHM[/youtube]. Next, it will convert it to html code.But instead of video,i want to show also the image of the video. So i do it like this:
$string = preg_replace("~\[yt]http://www.youtube.com/watch\?v=(.*)\[/yt]~Uis","<img src=\"http://img.youtube.com/vi/\\1/0.jpg\" />", $string);
It shows the image, but when somebody puts a url like:
http://www.youtube.com/watch?v=ihK2pPcDSHM&feature=channel
Then the image url becomes http://img.youtube.com/vi/ihK2pPcDSHM&feature=channel1/0.jpg which does not lead to a valid image. I am trying to change the \\1 to ".substr('\\1', 0,11)." but it doesnt have any result.
Any suggestion to solve this? Thanks!
1 year 19 weeks ago