bring back inline images
This commit is contained in:
parent
43f5fbddc6
commit
219fe3a8e7
@ -57,7 +57,7 @@ function bb_unspacefy_and_trim($st) {
|
|||||||
return $unspacefied;
|
return $unspacefied;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(! function_exists('bb_extract_images')) {
|
|
||||||
function bb_extract_images($body) {
|
function bb_extract_images($body) {
|
||||||
|
|
||||||
$saved_image = array();
|
$saved_image = array();
|
||||||
@ -97,24 +97,27 @@ function bb_extract_images($body) {
|
|||||||
$new_body = $new_body . $orig_body;
|
$new_body = $new_body . $orig_body;
|
||||||
|
|
||||||
return array('body' => $new_body, 'images' => $saved_image);
|
return array('body' => $new_body, 'images' => $saved_image);
|
||||||
}}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(! function_exists('bb_replace_images')) {
|
|
||||||
function bb_replace_images($body, $images) {
|
function bb_replace_images($body, $images) {
|
||||||
|
|
||||||
$newbody = $body;
|
$newbody = $body;
|
||||||
|
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
|
if(! $images)
|
||||||
|
return $newbody;
|
||||||
|
|
||||||
foreach($images as $image) {
|
foreach($images as $image) {
|
||||||
// We're depending on the property of 'foreach' (specified on the PHP website) that
|
// 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
|
// it loops over the array starting from the first element and going sequentially
|
||||||
// to the last element
|
// 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++;
|
$cnt++;
|
||||||
}
|
}
|
||||||
|
// logger('replace_images: ' . $newbody);
|
||||||
return $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);
|
$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 = preg_replace("/\<(.*?)(src|href)=\"[^hfm#](.*?)\>/ism",'<$1$2="">',$Text);
|
||||||
|
|
||||||
|
$Text = bb_replace_images($Text,$saved_images);
|
||||||
|
|
||||||
call_hooks('bbcode',$Text);
|
call_hooks('bbcode',$Text);
|
||||||
|
|
||||||
return $Text;
|
return $Text;
|
||||||
|
Reference in New Issue
Block a user