aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-03-11 18:04:43 -0700
committerfriendica <info@friendica.com>2015-03-11 18:04:43 -0700
commit1b3fee05e6db1fa80cd1a76395fa9e558e1e53c4 (patch)
tree0c721340e67c529c761ab643d4d0ea741dcd8098
parentd6ce32ef7885579ba0503bc7a826ded2ddac4d71 (diff)
downloadvolse-hubzilla-1b3fee05e6db1fa80cd1a76395fa9e558e1e53c4.tar.gz
volse-hubzilla-1b3fee05e6db1fa80cd1a76395fa9e558e1e53c4.tar.bz2
volse-hubzilla-1b3fee05e6db1fa80cd1a76395fa9e558e1e53c4.zip
turn parse_url into the definitive url attaching mechanism
-rw-r--r--include/bbcode.php22
-rwxr-xr-xinclude/oembed.php16
2 files changed, 35 insertions, 3 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index aa6641ca2..32e5d014f 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -756,11 +756,17 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
// html5 video and audio
if (strpos($Text,'[/video]') !== false) {
- $Text = preg_replace_callback("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4))\[\/video\]/ism", 'tryzrlvideo', $Text);
+ $Text = preg_replace_callback("/\[video\](.*?\.(ogg|ogv|oga|ogm|webm|mp4|mpeg|mpg))\[\/video\]/ism", 'tryzrlvideo', $Text);
}
if (strpos($Text,'[/audio]') !== false) {
$Text = preg_replace_callback("/\[audio\](.*?\.(ogg|ogv|oga|ogm|webm|mp4|mp3|opus))\[\/audio\]/ism", 'tryzrlaudio', $Text);
}
+ if (strpos($Text,'[/zvideo]') !== false) {
+ $Text = preg_replace_callback("/\[zvideo\](.*?\.(ogg|ogv|oga|ogm|webm|mp4|mpeg|mpg))\[\/zvideo\]/ism", 'tryzrlvideo', $Text);
+ }
+ if (strpos($Text,'[/zaudio]') !== false) {
+ $Text = preg_replace_callback("/\[zaudio\](.*?\.(ogg|ogv|oga|ogm|webm|mp4|mp3|opus))\[\/zaudio\]/ism", 'tryzrlaudio', $Text);
+ }
// Try to Oembed
if ($tryoembed) {
@@ -771,6 +777,13 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
if (strpos($Text,'[/audio]') !== false) {
$Text = preg_replace_callback("/\[audio\](.*?)\[\/audio\]/ism", 'tryoembed', $Text);
}
+
+ if (strpos($Text,'[/zvideo]') !== false) {
+ $Text = preg_replace_callback("/\[zvideo\](.*?)\[\/zvideo\]/ism", 'tryoembed', $Text);
+ }
+ if (strpos($Text,'[/zaudio]') !== false) {
+ $Text = preg_replace_callback("/\[zaudio\](.*?)\[\/zaudio\]/ism", 'tryoembed', $Text);
+ }
}
// if video couldn't be embedded, link to it instead.
@@ -781,6 +794,13 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = preg_replace("/\[audio\](.*?)\[\/audio\]/", '<a href="$1">$1</a>', $Text);
}
+ if (strpos($Text,'[/zvideo]') !== false) {
+ $Text = preg_replace("/\[zvideo\](.*?)\[\/zvideo\]/", '<a class="zid" href="$1">$1</a>', $Text);
+ }
+ if (strpos($Text,'[/zaudio]') !== false) {
+ $Text = preg_replace("/\[zaudio\](.*?)\[\/zaudio\]/", '<a class="zid" href="$1">$1</a>', $Text);
+ }
+
diff --git a/include/oembed.php b/include/oembed.php
index 38c433e99..ea91ec22b 100755
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -8,13 +8,25 @@ function oembed_replacecb($matches){
}
+// if the url is embeddable with oembed, return the bbcode link.
+
+function oembed_process($url) {
+ $j = oembed_fetch_url($url);
+ logger('oembed_process: ' . print_r($j,true));
+ if($j && $j->type !== 'error')
+ return '[embed]' . $url . '[/embed]';
+ return false;
+}
+
+
+
function oembed_fetch_url($embedurl){
$a = get_app();
$txt = Cache::get($a->videowidth . $embedurl);
- if(strstr($txt,'youtu')) {
+ if(strstr($txt,'youtu') && strstr(z_root(),'https:')) {
$txt = str_replace('http:','https:',$txt);
}
@@ -105,7 +117,7 @@ function oembed_format_object($j){
$th=120; $tw = $th*$tr;
$tpl=get_markup_template('oembed_video.tpl');
- if(strstr($embedurl,'youtu')) {
+ if(strstr($embedurl,'youtu') && strstr(z_root(),'https:')) {
$embedurl = str_replace('http:','https:',$embedurl);
$j->thumbnail_url = str_replace('http:','https:', $j->thumbnail_url);
$jhtml = str_replace('http:','https:', $jhtml);