aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xinclude/items.php25
-rw-r--r--mod/item.php5
2 files changed, 30 insertions, 0 deletions
diff --git a/include/items.php b/include/items.php
index 7a94336be..5aaeb55c0 100755
--- a/include/items.php
+++ b/include/items.php
@@ -239,6 +239,31 @@ function red_unescape_codeblock($m) {
}
+function red_zrlify_img_callback($matches) {
+ $m = @parse_url($matches[2]);
+ $zrl = false;
+ if($m['host']) {
+ $r = q("select hubloc_url from hubloc where hubloc_host = '%s' limit 1",
+ dbesc($m['host'])
+ );
+ if($r)
+ $zrl = true;
+ }
+
+ $t = strip_zids($matches[2]);
+ if($t !== $matches[2]) {
+ $zrl = true;
+ $matches[2] = $t;
+ }
+
+ if($zrl)
+ return '[zmg' . $matches[1] . ']' . $matches[2] . '[/zmg]';
+ return $matches[0];
+}
+
+
+
+
/**
* @function post_activity_item($arr)
*
diff --git a/mod/item.php b/mod/item.php
index 164b345f0..9470a2b9c 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -440,6 +440,11 @@ function item_post(&$a) {
$body = preg_replace_callback('/\[\$b64url(.*?)\[\/(url)\]/ism','red_unescape_codeblock',$body);
$body = preg_replace_callback('/\[\$b64code(.*?)\[\/(code)\]/ism','red_unescape_codeblock',$body);
+ // fix any img tags that should be zmg
+
+ $body = preg_replace_callback('/\[img(.*?)\](.*?)\[\/img\]/ism','red_zrlify_img_callback',$body);
+
+
/**
*