mirror of
https://github.com/e107inc/e107.git
synced 2025-04-14 01:22:13 +02:00
Convert images back to bbcode when using TinyMce to keep image src urls dynamic. Parse bbcode inside [html] in toHtml()
This commit is contained in:
parent
b1a2e65a9b
commit
66cb38cb85
@ -70,7 +70,7 @@ class bb_img extends e_bb_base
|
||||
// $resize = "&w=".$w; // Always resize - otherwise the thumbnailer returns nothing.
|
||||
// $parmStr = implode(" ",$p);
|
||||
|
||||
// print_a($imgParms);
|
||||
|
||||
|
||||
// $url = e107::getParser()->thumbUrl($code_text, $resize);
|
||||
|
||||
@ -132,8 +132,10 @@ class bb_img extends e_bb_base
|
||||
}
|
||||
|
||||
$imgParms['title'] = $imgParms['alt'] ;
|
||||
|
||||
$imgParms['class'] = "img-rounded rounded bbcode ".e107::getBB()->getClass('img');; // This will be overridden if a new class is specified
|
||||
|
||||
$class = !empty($imgParms['class']) ? ' '.$imgParms['class'] : '';
|
||||
|
||||
$imgParms['class'] = "img-rounded rounded bbcode ".e107::getBB()->getClass('img').$class; // This will be overridden if a new class is specified
|
||||
|
||||
if($mode == 'string')
|
||||
{
|
||||
@ -165,7 +167,7 @@ class bb_img extends e_bb_base
|
||||
}
|
||||
|
||||
|
||||
|
||||
var_dump($code_text);
|
||||
|
||||
if (preg_match("#\.php\?.*#",$code_text)){return "";} //XXX Breaks MediaManager Images, so do it after mediaManager check.
|
||||
|
||||
|
@ -1479,6 +1479,34 @@ class e_parse extends e_parser
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function parseBBCodes($text, $postID)
|
||||
{
|
||||
if (!is_object($this->e_bb))
|
||||
{
|
||||
require_once(e_HANDLER.'bbcode_handler.php');
|
||||
$this->e_bb = new e_bbcode;
|
||||
}
|
||||
|
||||
|
||||
$text = $this->e_bb->parseBBCodes($text, $postID);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts the text (presumably retrieved from the database) for HTML output.
|
||||
*
|
||||
@ -1687,10 +1715,14 @@ class e_parse extends e_parser
|
||||
$html_start = "<!-- bbcode-html-start -->"; // markers for html-to-bbcode replacement.
|
||||
$html_end = "<!-- bbcode-html-end -->";
|
||||
$full_text = str_replace(array("[html]","[/html]"), "",$code_text); // quick fix.. security issue?
|
||||
$full_text =$this->replaceConstants($full_text,'abs');
|
||||
|
||||
$full_text = $this->parseBBCodes($full_text, $postID); // parse any embedded bbcodes eg. [img]
|
||||
$full_text = $this->replaceConstants($full_text,'abs'); // parse any other paths using {e_....
|
||||
$full_text = $html_start.$full_text.$html_end;
|
||||
$full_text = $this->parseBBTags($full_text); // strip <bbcode> tags.
|
||||
$opts['nobreak'] = true;
|
||||
$parseBB = false; // prevent further bbcode processing.
|
||||
|
||||
|
||||
break;
|
||||
|
||||
@ -2764,6 +2796,8 @@ class e_parse extends e_parser
|
||||
|
||||
$staticFile = $this->thumbCacheFile($url, $opts);
|
||||
|
||||
|
||||
|
||||
if(!empty($staticFile) && is_readable(e_CACHE_IMAGE.$staticFile))
|
||||
{
|
||||
$staticImg = $this->staticUrl(e_CACHE_IMAGE_ABS.$staticFile);
|
||||
@ -2771,6 +2805,8 @@ class e_parse extends e_parser
|
||||
return $staticImg;
|
||||
}
|
||||
|
||||
// echo "<br />static-not-found: ".$staticFile;
|
||||
|
||||
$options['nosef'] = true;
|
||||
$options['x'] = null;
|
||||
// file_put_contents(e_LOG."thumb.log", "\n++++++++++++++++++++++++++++++++++\n\n", FILE_APPEND);
|
||||
|
@ -194,17 +194,6 @@ TEMPL;
|
||||
{
|
||||
|
||||
$content = trim($content);
|
||||
|
||||
// $srch = array('src="'.e_HTTP.'thumb.php?','src="/{e_MEDIA_IMAGE}');
|
||||
// $repl = array('src="{e_BASE}thumb.php?','src="{e_BASE}thumb.php?src=e_MEDIA_IMAGE/');
|
||||
// $content = str_replace($srch, $repl, $content);
|
||||
|
||||
// resize the thumbnail to match wysiwyg width/height.
|
||||
|
||||
// $psrch = '/<img[^>]*src="{e_BASE}thumb.php\?src=([\S]*)w=([\d]*)&h=([\d]*)"(.*)width="([\d]*)" height="([\d]*)"/i';
|
||||
// $prepl = '<img src="{e_BASE}thumb.php?src=$1w=$5&h=$6"$4width="$5" height="$6" ';
|
||||
|
||||
// $content = preg_replace($psrch, $prepl, $content);
|
||||
$content = $this->updateImg($content);
|
||||
// $content = $tp->parseBBTags($content,true); // replace html with bbcode equivalent
|
||||
|
||||
@ -307,7 +296,7 @@ TEMPL;
|
||||
|
||||
|
||||
$regexp = '#(<img[^>]*src="'.str_replace($srch, $repl, $img['src']).'"[^>]*>)#';
|
||||
|
||||
/*
|
||||
$width = vartrue($img['width']) ? ' width="'.$img['width'].'"' : '';
|
||||
$height = vartrue($img['height']) ? ' height="'.$img['height'].'"' : '';
|
||||
$style = vartrue($img['style']) ? ' style="'.$img['style'].'"' : '';
|
||||
@ -315,6 +304,8 @@ TEMPL;
|
||||
$alt = vartrue($img['alt']) ? ' alt="'.$img['alt'].'"' : '';
|
||||
$title = vartrue($img['title']) ? ' title="'.$img['title'].'"' : '';
|
||||
$srcset = vartrue($img['srcset']) ? 'srcset="'.$img['srcset'].'"' : '';
|
||||
*/
|
||||
|
||||
|
||||
$qr = $this->thumbUrlDecode($img['src']);
|
||||
|
||||
@ -326,9 +317,43 @@ TEMPL;
|
||||
|
||||
$qr['ebase'] = true;
|
||||
|
||||
$src = e107::getParser()->thumbUrl($qr['src'],$qr);
|
||||
// $src = e107::getParser()->thumbUrl($qr['src'],$qr);
|
||||
|
||||
$replacement = '<img src="'.$src.'" '.$srcset.$style.$alt.$title.$class.$width.$height.' />';
|
||||
// $replacement = '<img src="'.$src.'" '.$srcset.$style.$alt.$title.$class.$width.$height.' />';
|
||||
|
||||
unset($img['src'],$img['srcset'],$img['@value'], $img['caption'], $img['alt']);
|
||||
|
||||
if(!empty($img['class']))
|
||||
{
|
||||
$tmp = explode(" ",$img['class']);
|
||||
$cls = array();
|
||||
foreach($tmp as $v)
|
||||
{
|
||||
if($v === 'img-rounded' || $v === 'rounded' || $v === 'bbcode' || $v === 'bbcode-img-news' || $v === 'bbcode-img')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$cls[] = $v;
|
||||
|
||||
}
|
||||
|
||||
if(empty($cls))
|
||||
{
|
||||
unset($img['class']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$img['class'] = implode(" ",$cls);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$parms = !empty($img) ? ' '.str_replace('+', ' ', http_build_query($img,null, '&')) : "";
|
||||
|
||||
$code_text = str_replace(e107::getParser()->getUrlConstants('raw'), e107::getParser()->getUrlConstants('sc'), $qr['src']);
|
||||
|
||||
$replacement = '[img'.$parms.']'.$code_text.'[/img]';
|
||||
|
||||
$text = preg_replace($regexp, $replacement, $text);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user