Commit 4cac95d9 authored by Zot's avatar Zot

provide limited but hopefully adequate support for new Diaspora html5...

provide limited but hopefully adequate support for new Diaspora html5 audio/video using regular link or image tags and sniffing the urls for media file extensions.
parent 99c21f07
......@@ -1070,6 +1070,8 @@ function diaspora_markdown_to_bb_init(&$s) {
// if empty link text replace with the url
$s = preg_replace("/\[\]\((.*?)\)/ism",'[$1]($1)',$s);
$s = preg_replace_callback("/\!*\[(.*?)\]\((.*?)\)/ism",'diaspora_markdown_media_cb',$s);
$s = preg_replace_callback('/\@\{(.+?)\; (.+?)\@(.+?)\}\+/','diaspora_md_mention_callback',$s);
$s = preg_replace_callback('/\@\{(.+?)\; (.+?)\@(.+?)\}/','diaspora_md_mention_callback',$s);
......@@ -1085,6 +1087,24 @@ function diaspora_markdown_to_bb_init(&$s) {
}
function diaspora_markdown_media_cb($matches) {
$audios = [ '.mp3', '.ogg', '.oga', '.m4a' ];
$videos = [ '.mp4', '.ogv', '.ogm', '.webm', '.opus' ];
foreach($audios as $aud) {
if(strpos(strtolower($matches[2]),$aud) !== false)
return '[audio]' . $matches[2] . '[/audio]';
}
foreach($videos as $vid) {
if(strpos(strtolower($matches[2]),$vid) !== false)
return '[video]' . $matches[2] . '[/video]';
}
return $matches[0];
}
function diaspora_bb_to_markdown_bb(&$x) {
if(! in_array('diaspora',$x['options']))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment