Created
August 2, 2011 14:03
-
-
Save marcoraddatz/1120243 to your computer and use it in GitHub Desktop.
url2video: BBCode example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# using [audio]file.ext[/audio] | |
if (preg_match('#\[audio\](.*)\[\/audio\]#Uis', $sStr, $aMatch)) { | |
$sUrl = 'http://url2video.com/?url=' . $aMatch[1] . '&w=' . MEDIA_DEFAULT_X . '&h=30&callback=?'; | |
$sStr = preg_replace('#\[audio\](.*)\[\/audio\]#Uis', | |
'<div class="js-media" title="' . $sUrl . '"><a href="' . $sUrl . '">' . $aMatch[1] . '</a></div>', | |
$sStr); | |
} | |
# [video]file[/video] | |
if (preg_match('#\[video\](.*)\[\/video\]#Uis', $sStr, $aMatch)) { | |
$sUrl = 'http://url2video.com/?url=' . $aMatch[1] . '&w=' . MEDIA_DEFAULT_X . '&h=' . MEDIA_DEFAULT_Y . '&callback=?'; | |
$sStr = preg_replace('#\[video\](.*)\[\/video\]#Uis', | |
'<a href="' . $aMatch[1] . '" class="js-media" title="' . $sUrl . '">' . $aMatch[1] . '</a>', | |
$sStr); | |
} | |
# [video thumbnail]file[/video] | |
if (preg_match('#\[video (.*)\](.*)\[\/video]#Uis', $sStr, $aMatch)) { | |
$sUrl = 'http://url2video.com/?url=' . $aMatch[2] . '&w=' . MEDIA_DEFAULT_X . '&h=' . MEDIA_DEFAULT_Y . '&p=' . $aMatch[1] . '&callback=?'; | |
$sStr = preg_replace('#\[video (.*)\](.*)\[\/video]#Uis', | |
'<div class="js-media" title="' . $sUrl . '"><a href="' . $aMatch[2] . '">' . $aMatch[2] . '</a></div>', | |
$sStr); | |
} | |
# [video width height thumbnail]file[/video] | |
if (preg_match('#\[video ([0-9]+) ([0-9]+) (.*)\](.*)\[\/video\]#Uis', $sStr, $aMatch)) { | |
$sUrl = 'http://url2video.com/?url=' . $aMatch[4] . '&w=' . $aMatch[1] . '&h=' . $aMatch[2] . '&p=' . $aMatch[3] . '&callback=?'; | |
$sStr = preg_replace('#\[video ([0-9]+) ([0-9]+) (.*)\](.*)\[\/video\]#Uis', | |
'<div class="js-media" title="' . $sUrl . '"><a href="' . $aMatch[4] . '" class="js-media">' . $aMatch[4] . '</a></div>', | |
$sStr); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment