aboutsummaryrefslogtreecommitdiffstats
path: root/include/bbcode.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-31 00:50:20 -0800
committerfriendica <info@friendica.com>2015-01-31 00:50:20 -0800
commite6a5f7800390e5091743d6a97c6fd8f54c5d1530 (patch)
tree20c49c7d11b411b91530ef43374a208274ebbb57 /include/bbcode.php
parent4a243b63f7019a1e56ecf03b138cd7fc396236c2 (diff)
parent3e5226adc70838c784a0b208de25fffde37a6679 (diff)
downloadvolse-hubzilla-e6a5f7800390e5091743d6a97c6fd8f54c5d1530.tar.gz
volse-hubzilla-e6a5f7800390e5091743d6a97c6fd8f54c5d1530.tar.bz2
volse-hubzilla-e6a5f7800390e5091743d6a97c6fd8f54c5d1530.zip
Merge branch 'master' into tres
Conflicts: include/zot.php
Diffstat (limited to 'include/bbcode.php')
-rw-r--r--include/bbcode.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/include/bbcode.php b/include/bbcode.php
index 5504dce7a..7067fcd39 100644
--- a/include/bbcode.php
+++ b/include/bbcode.php
@@ -57,7 +57,7 @@ function bb_unspacefy_and_trim($st) {
return $unspacefied;
}
-if(! function_exists('bb_extract_images')) {
+
function bb_extract_images($body) {
$saved_image = array();
@@ -97,24 +97,27 @@ function bb_extract_images($body) {
$new_body = $new_body . $orig_body;
return array('body' => $new_body, 'images' => $saved_image);
-}}
+}
+
-if(! function_exists('bb_replace_images')) {
function bb_replace_images($body, $images) {
$newbody = $body;
$cnt = 0;
+ if(! $images)
+ return $newbody;
+
foreach($images as $image) {
// We're depending on the property of 'foreach' (specified on the PHP website) that
// it loops over the array starting from the first element and going sequentially
// to the last element
- $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '<img class="zrl" src="' . $image .'" alt="' . t('Image/photo') . '" />', $newbody);
+ $newbody = str_replace('[$#saved_image' . $cnt . '#$]', '<img src="' . $image .'" alt="' . t('Image/photo') . '" />', $newbody);
$cnt++;
}
-
+// logger('replace_images: ' . $newbody);
return $newbody;
-}}
+}
@@ -404,6 +407,10 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
}
+ $x = bb_extract_images($Text);
+ $Text = $x['body'];
+ $saved_images = $x['images'];
+
$Text = str_replace(array('[baseurl]','[sitename]'),array(z_root(),get_config('system','sitename')),$Text);
@@ -853,6 +860,8 @@ function bbcode($Text,$preserve_nl = false, $tryoembed = true) {
$Text = preg_replace("/\<(.*?)(src|href)=\"[^hfm#](.*?)\>/ism",'<$1$2="">',$Text);
+ $Text = bb_replace_images($Text,$saved_images);
+
call_hooks('bbcode',$Text);
return $Text;