1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00

Issue #1257 More work on SEF Thumb URLs.

This commit is contained in:
Cameron 2016-02-04 11:40:15 -08:00
parent 27c2a07d25
commit 0c3125a11e
3 changed files with 62 additions and 27 deletions

View File

@ -1310,10 +1310,10 @@ class media_admin_ui extends e_admin_ui
$br = (E107_DEBUG_LEVEL > 0) ? "<br />" : "";
$text .= "
".$br."<input title='bbcode' type='{$type}' readonly='readonly' class='span11' id='bbcode_holder' name='bbcode_holder' value='' />
".$br."<input title='html/wysiwyg' type='{$type}' class='span11' readonly='readonly' id='html_holder' name='html_holder' value='' />
".$br."<input title='(preview) src' type='{$type}' class='span11' readonly='readonly' id='src' name='src' value='' />
".$br."<input title='path (saved to db)' type='{$type}' class='span11' readonly='readonly' id='path' name='path' value='' />
".$br."<input title='bbcode' type='{$type}' readonly='readonly' class='span11 col-md-11' id='bbcode_holder' name='bbcode_holder' value='' />
".$br."<input title='html/wysiwyg' type='{$type}' class='span11 col-md-11' readonly='readonly' id='html_holder' name='html_holder' value='' />
".$br."<input title='(preview) src' type='{$type}' class='span11 col-md-11' readonly='readonly' id='src' name='src' value='' />
".$br."<input title='path (saved to db)' type='{$type}' class='span11 col-md-11' readonly='readonly' id='path' name='path' value='' />
";
return $text;

View File

@ -42,8 +42,8 @@ class bb_img extends e_bb_base
// Replace the bbcode path with a real one.
$code_text = str_replace('{e_MEDIA}images/','{e_MEDIA_IMAGE}',$code_text); //BC 0.8 fix.
$code_text = str_replace('{e_MEDIA_IMAGE}', e_HTTP."thumb.php?src=e_MEDIA_IMAGE/", $code_text);
$code_text = str_replace('{e_THEME}', e_HTTP."thumb.php?src=e_THEME/", $code_text);
// $code_text = str_replace('{e_MEDIA_IMAGE}', e_HTTP."thumb.php?src=e_MEDIA_IMAGE/", $code_text);
// $code_text = str_replace('{e_THEME}', e_HTTP."thumb.php?src=e_THEME/", $code_text);
$imgParms = $this->processParm($code_text, $parm);
$figcaption = false;
@ -61,10 +61,6 @@ class bb_img extends e_bb_base
$p[] = $tp->toAttribute($k).'="'.$tp->toAttribute($v).'"';
}
// $w = e107::getBB()->resizeWidth(); // varies depending on the class set by external script. see admin->media-manager->prefs
$w = vartrue($imgParms['width']) ? intval($imgParms['width']) : vartrue(e107::getBB()->resizeWidth(),0);
// $h = vartrue($imgParms['height']) ? intval($imgParms['height']) : e107::getBB()->resizeHeight();
@ -74,11 +70,12 @@ class bb_img extends e_bb_base
// print_a($imgParms);
// print_a($parmStr);
$url = e107::getParser()->thumbUrl($code_text, $resize);
if(!empty($figcaption))
{
$html = "<figure>\n";
$html .= "<img src=\"".$code_text.$resize."\" {$parmStr} />\n";
$html .= "<img src=\"".$url."\" {$parmStr} />";
$html .= "<figcaption>".e107::getParser()->filter($figcaption,'str')."</figcaption>\n";
$html .= "</figure>";
@ -86,7 +83,7 @@ class bb_img extends e_bb_base
}
else
{
return "<img src=\"".$code_text.$resize."\" {$parmStr} />";
return "<img src=\"".$url."\" {$parmStr} />";
}
}

View File

@ -8,7 +8,7 @@
*/
if(empty($_POST['content']) && empty($_GET['debug']))
if(empty($_POST['content']) && empty($_GET['debug']) && !defined('TINYMCE_DEBUG'))
{
header('Content-Length: 0');
exit;
@ -17,7 +17,11 @@ if(empty($_POST['content']) && empty($_GET['debug']))
$_E107['no_online'] = true;
$_E107['no_menus'] = true;
$_E107['no_forceuserupdate'] = true;
require_once("../../../../class2.php");
if(!defined('TINYMCE_DEBUG'))
{
require_once("../../../../class2.php");
}
/**
* Two Modes supported below going to and from the Tinymce wysiwyg editor.
@ -29,7 +33,7 @@ require_once("../../../../class2.php");
class e107TinyMceParser
{
protected $gzipCompression = true;
protected $gzipCompression = false;
/**
*
@ -38,6 +42,11 @@ class e107TinyMceParser
{
$html = '';
if(defined('TINYMCE_DEBUG'))
{
$this->gzipCompression = false;
}
if(!empty($_GET['debug']) && getperms('0'))
{
$debug = true; // For future use.
@ -213,8 +222,42 @@ TEMPL;
}
/**
* Split a thumb.php url into an array which can be parsed back into the thumbUrl method. .
* @param $src
* @return array
*/
function thumbUrlDecode($src)
{
list($url,$qry) = explode("?",$src);
$ret = array();
if(strstr($url,"thumb.php") && !empty($qry)) // Regular
{
parse_str($qry,$val);
$ret = $val;
}
elseif(preg_match('/media\/img\/(a)?([\d]*)x(a)?([\d]*)\/(.*)/',$url,$match)) // SEF
{
$wKey = $match[1].'w';
$hKey = $match[3].'h';
$ret = array(
'src'=> 'e_MEDIA_IMAGE/'.$match[5],
$wKey => $match[2],
$hKey => $match[4]
);
}
return $ret;
}
/**
* Rebuld <img> tags with modified thumbnail size.
* @param $text
* @return mixed
*/
function updateImg($text)
{
@ -235,34 +278,29 @@ TEMPL;
$alt = vartrue($img['alt']) ? ' alt="'.$img['alt'].'"' : '';
$title = vartrue($img['title']) ? ' title="'.$img['title'].'"' : '';
list($url,$qry) = explode("?",$img['src']);
$qr = $this->thumbUrlDecode($img['src']);
parse_str($qry,$qr);
if(substr($url,0,4)!=='http' && empty($qr['w']) && empty($qr['aw']))
if(substr($qr['src'],0,4)!=='http' && empty($qr['w']) && empty($qr['aw']))
{
$qr['w'] = $img['width'];
$qr['h'] = $img['height'];
}
$src = $url."?".urldecode(http_build_query($qr));
$src = e107::getParser()->thumbUrl($qr['src'],$qr);
$replacement = '<img'.$class.$style.' src="'.$src.'"'.$width.$height.$alt.$title.' />';
$replacement = '<img src="'.$src.'" '.$style.$alt.$title.$class.$width.$height.' />';
$text = preg_replace($regexp, $replacement, $text);
}
return $text;
}
}
new e107TinyMceParser();
$mce = new e107TinyMceParser();
?>