try naked embed before submission instead of at render time
This commit is contained in:
parent
3250d75320
commit
48f70e55aa
@ -20,6 +20,8 @@ namespace Zotlabs\Module;
|
||||
require_once('include/crypto.php');
|
||||
require_once('include/items.php');
|
||||
require_once('include/attach.php');
|
||||
require_once('include/bbcode.php');
|
||||
|
||||
|
||||
use \Zotlabs\Lib as Zlib;
|
||||
|
||||
@ -550,6 +552,8 @@ class Item extends \Zotlabs\Web\Controller {
|
||||
$body = preg_replace_callback('/\[url(.*?)\[\/(url)\]/ism','\red_escape_codeblock',$body);
|
||||
$body = preg_replace_callback('/\[zrl(.*?)\[\/(zrl)\]/ism','\red_escape_codeblock',$body);
|
||||
|
||||
|
||||
$body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ism", 'nakedoembed', $body);
|
||||
$body = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,]+)/ism", '\red_zrl_callback', $body);
|
||||
|
||||
$body = preg_replace_callback('/\[\$b64zrl(.*?)\[\/(zrl)\]/ism','\red_unescape_codeblock',$body);
|
||||
|
@ -12,7 +12,6 @@ require_once('include/hubloc.php');
|
||||
function tryoembed($match) {
|
||||
$url = ((count($match) == 2) ? $match[1] : $match[2]);
|
||||
|
||||
|
||||
$o = oembed_fetch_url($url);
|
||||
|
||||
if ($o['type'] == 'error')
|
||||
@ -22,6 +21,18 @@ function tryoembed($match) {
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
function nakedoembed($match) {
|
||||
$url = ((count($match) == 2) ? $match[1] : $match[2]);
|
||||
|
||||
$o = oembed_fetch_url($url);
|
||||
|
||||
if ($o['type'] == 'error')
|
||||
return $match[0];
|
||||
|
||||
return '[embed]' . $url . '[/embed]';
|
||||
}
|
||||
|
||||
function tryzrlaudio($match) {
|
||||
$link = $match[1];
|
||||
$zrl = is_matrix_url($link);
|
||||
@ -645,6 +656,9 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false)
|
||||
$urlchars = '[a-zA-Z0-9\:\/\-\?\&\;\.\=\@\_\~\#\%\$\!\+\,\@]';
|
||||
|
||||
if (strpos($Text,'http') !== false) {
|
||||
if($tryoembed) {
|
||||
$Text = preg_replace_callback("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/$urlchars+)/ism", 'tryoembed', $Text);
|
||||
}
|
||||
$Text = preg_replace("/([^\]\='".'"'."\/]|^|\#\^)(https?\:\/\/$urlchars+)/ism", '$1<a href="$2" target="_blank" >$2</a>', $Text);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user