1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-22 13:41:52 +02:00

Cleaned up the Default Image Size in Media-Manager Preference area. Remove 'width=' from [img] when it matches the default size.

This commit is contained in:
Cameron 2018-01-26 15:54:54 -08:00
parent 4d3ef86bb7
commit c162981fbd
6 changed files with 63 additions and 34 deletions
e107_admin
e107_core/bbcodes
e107_handlers
e107_languages/English/admin
e107_plugins/tinymce4/plugins/e107

@ -593,41 +593,51 @@ class media_form_ui extends e_admin_form_ui
{
$text = "";
$frm = e107::getForm();
$pref = e107::getPref();
$options = array(
"news-image" => LAN_IMA_O_001,
"news-bbcode" => LAN_IMA_O_002,
"page-bbcode" => LAN_IMA_O_003,
// "news-image" => LAN_IMA_O_001,
// "news-bbcode" => LAN_IMA_O_002,
// "page-bbcode" => LAN_IMA_O_003,
// "featurebox-image" => LAN_IMA_O_004,
// "featurebox-bbcode" => LAN_IMA_O_005,
);
if(vartrue($pref['e_imageresize']) && is_array($pref['e_imageresize']))
$options = $pref['resize_dimensions'];
/* @deprecated */
if(!empty($pref['e_imageresize']) && is_array($pref['e_imageresize']))
{
foreach($pref['e_imageresize'] as $k=>$val)
{
$options[$k] = ucfirst($k)." ".LAN_IMA_O_006;
}
}
$options = $pref['resize_dimensions'];
unset($options['news-image']); /* @deprecated */
$text = "<table class='table table-striped table-condensed table-bordered' style='width:400px; margin-bottom:0'>
<tr>
<th>".LAN_TYPE."</th>
<th class='text-right'>".LAN_WIDTH."</th>
<th class='text-right'>".LAN_HEIGHT."</th>
</tr>\n";
foreach($options as $key=>$title)
{
$title = ucwords(str_replace("-"," ",$key));
$valW = vartrue($curval[$key]['w']);
$valH = vartrue($curval[$key]['h']);
$text .= "<div style='margin-bottom:8px; text-align:right; width:400px'>".$title.": ";
$text .= "<input class='e-tip e-spinner input-small' placeholder='ex. 400' style='text-align:right' type='text' name='resize_dimensions[{$key}][w]' value='$valW' size='5' title='maximum width in pixels' /> X ";
$text .= "<input class='e-tip e-spinner input-small' placeholder='ex. 400' style='text-align:right' type='text' name='resize_dimensions[{$key}][h]' value='$valH' size='5' title='maximum height in pixels' />";
$text .= "</div>";
// $text .= $frm->text("resize_dimensions[{$key}]",$val, 5, array('size'=>'5')).$title."<br />";
}
$text .= "<tr><td style='width:45%'>".$title."</td><td class='text-right'>";
$text .= "<input class='e-tip e-spinner input-small' placeholder='ex. 400' style='text-align:right' type='text' name='resize_dimensions[{$key}][w]' value='$valW' size='5' title='maximum width in pixels' />";
$text .= "</td><td class='text-right'><input class='e-tip e-spinner input-small' placeholder='ex. 400' style='text-align:right' type='text' name='resize_dimensions[{$key}][h]' value='$valH' size='5' title='maximum height in pixels' />";
$text .= "</td></tr>";
}
$text .= "</table>";
// $text .= "<div><br />Warning: This feature is experimental.</div>";
@ -886,7 +896,7 @@ class media_admin_ui extends e_admin_ui
'im_width' => array('title'=> IMALAN_75, 'type'=>'number', 'data'=>'int', 'writeParms'=>'', 'help'=>IMALAN_76),
'im_height' => array('title'=> IMALAN_77, 'type'=>'number', 'data'=>'int', 'writeParms'=>'', 'help'=>IMALAN_76),
'resize_dimensions' => array('title'=> IMALAN_79, 'type'=>'method', 'data'=>'str'),
'resize_dimensions' => array('title'=> IMALAN_184, 'type'=>'method', 'data'=>'str'),
'watermark_activate' => array('title'=> IMALAN_80, 'tab'=>1, 'type' => 'number', 'data' => 'str', 'help'=>IMALAN_81), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
'watermark_text' => array('title'=> IMALAN_82,'tab'=>1, 'type' => 'text', 'data' => 'str', 'help'=>IMALAN_83), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),

@ -168,7 +168,7 @@ class bb_img extends e_bb_base
return $this->mediaImage($code_text, $parm);
}
if (preg_match("#\.php\?.*#",$code_text)){return "";} //XXX Breaks MediaManager Images, so do it after mediaManager check.
$addlink = FALSE;

@ -31,11 +31,14 @@ class e_bbcode
var $preProcess = FALSE; // Set when processing bbcodes prior to saving
var $core_bb = array();
var $class = FALSE;
private $resizePrefs = array();
function __construct()
{
$pref = e107::getPref();
$this->resizePrefs = $pref['resize_dimensions'];
$this->core_bb = array(
'alert',
'blockquote', 'img', 'i', 'u', 'center',
@ -483,21 +486,21 @@ class e_bbcode
function resizeWidth()
{
$pref = e107::getPref();
if($this->class && vartrue($pref['resize_dimensions'][$this->class.'-bbcode']['w']))
if($this->class && !empty($this->resizePrefs[$this->class.'-bbcode']['w']))
{
return $pref['resize_dimensions'][$this->class.'-bbcode']['w'];
return (int) $this->resizePrefs[$this->class.'-bbcode']['w'];
}
return false;
}
function resizeHeight()
{
$pref = e107::getPref();
if($this->class && vartrue($pref['resize_dimensions'][$this->class.'-bbcode']['h']))
if($this->class && !empty($this->resizePrefs[$this->class.'-bbcode']['h']))
{
return $pref['resize_dimensions'][$this->class.'-bbcode']['h'];
return (int) $this->resizePrefs[$this->class.'-bbcode']['h'];
}
return false;
}
@ -672,6 +675,10 @@ class e_bbcode
$html = str_replace('&quot;','"', $html);
}
// var_dump($this->defaultImageSizes);
$cl = $this->getClass();
$arr = $tp->getTags($html,'img');
$srch = array("?","&");
@ -729,8 +736,10 @@ class e_bbcode
}
if($this->resizeWidth() === (int) $img['width'])
{
unset($img['width']);
}
$code_text = (strpos($img['src'],'http') === 0) ? $img['src'] : str_replace($tp->getUrlConstants('raw'), $tp->getUrlConstants('sc'), $qr['src']);

@ -353,6 +353,7 @@ define("LAN_UPLOAD_CONFIRM","Any unsaved changes to this page will be lost. Cont
define("LAN_UPLOAD_777","Folder is missing or not writable, you need to CHMOD 777 the following folder before uploading:");
define("LAN_UPLOAD_SERVEROFF", "This option is disabled as file uploading is not enabled on your server");
define("LAN_WIDTH","Width");
define("LAN_HEIGHT","Height");
define("LAN_ON","On");
define("LAN_OFF", "Off");

@ -17,12 +17,16 @@ define("LAN_IMA_002", "Not enough memory available to rotate");
define("LAN_IMA_003", "Rotated");
define("LAN_IMA_004", "Resizing");
// Options
define("LAN_IMA_O_001", "News Images");
define("LAN_IMA_O_002", "News [img] bbcode");
define("LAN_IMA_O_003", "Page [img] bbcode");
define("LAN_IMA_O_004", "Featurebox Images");
define("LAN_IMA_O_005", "Featurebox [img] bbcode");
define("LAN_IMA_O_006", "[img] bbcode");
// define("LAN_IMA_O_001", "News Images");
// define("LAN_IMA_O_002", "News [img] bbcode");
// define("LAN_IMA_O_003", "Page [img] bbcode");
// define("LAN_IMA_O_004", "Featurebox Images");
// define("LAN_IMA_O_005", "Featurebox [img] bbcode");
// define("LAN_IMA_O_006", "[img] bbcode");
// Work in progress (Moc)
define("IMALAN_1", "Enable image display");
define("IMALAN_2", "Display images, this will apply sitewide (comments, chatbox etc) to images posted using the [img] bbcode");
@ -204,4 +208,5 @@ define("IMALAN_181", "Please remove before proceeding.");
define("IMALAN_182", "Convert to jpeg during import");
define("IMALAN_183", "PNG and GIF files will be automatically converted to jpeg format. (icons excluded)");
define("IMALAN_184", "Default Image Sizes");
define("IMALAN_185", "Maximum height in pixels");

@ -189,6 +189,9 @@ TEMPL;
{
// echo $_POST['content'];
global $pref, $tp;
e107::getBB()->setClass($_SESSION['media_category']);
$content = stripslashes($content);
if(check_class($pref['post_html'])) // Plain HTML mode.
@ -216,6 +219,7 @@ TEMPL;
$text = str_replace('[html]<p></p>[/html]','',$text); // cleanup.
e107::getBB()->clearClass();
return $text;
}