mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Tinymce Image-style fix
This commit is contained in:
@@ -972,12 +972,12 @@ class media_admin_ui extends e_admin_ui
|
|||||||
<li class='active'><a data-toggle='tab' href='#core-media-select'>Choose from Library</a></li>
|
<li class='active'><a data-toggle='tab' href='#core-media-select'>Choose from Library</a></li>
|
||||||
<li><a data-toggle='tab' href='#core-media-upload'>Upload a File</a></li>";
|
<li><a data-toggle='tab' href='#core-media-upload'>Upload a File</a></li>";
|
||||||
|
|
||||||
if($options['bbcode'])
|
if(varset($options['bbcode']))
|
||||||
{
|
{
|
||||||
$text .= "<li><a data-toggle='tab' href='#core-media-style'>Appearance</a></li>\n";
|
$text .= "<li><a data-toggle='tab' href='#core-media-style'>Appearance</a></li>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($_GET['from'])
|
if(varset($_GET['from']))
|
||||||
{
|
{
|
||||||
$options['from'] .= intval($_GET['from']);
|
$options['from'] .= intval($_GET['from']);
|
||||||
}
|
}
|
||||||
@@ -996,7 +996,7 @@ class media_admin_ui extends e_admin_ui
|
|||||||
|
|
||||||
$tag = ($options['bbcode']) ? "" : $this->getQuery('tagid');
|
$tag = ($options['bbcode']) ? "" : $this->getQuery('tagid');
|
||||||
|
|
||||||
if($_GET['w'])
|
if(varset($_GET['w']))
|
||||||
{
|
{
|
||||||
$options['w'] = intval($_GET['w']);
|
$options['w'] = intval($_GET['w']);
|
||||||
}
|
}
|
||||||
@@ -1039,7 +1039,9 @@ class media_admin_ui extends e_admin_ui
|
|||||||
{
|
{
|
||||||
$text .= "<div class='tab-pane' id='core-media-style'>
|
$text .= "<div class='tab-pane' id='core-media-style'>
|
||||||
<legend>Appearance</legend>
|
<legend>Appearance</legend>
|
||||||
<table class='table adminform'>
|
<div class='row'>
|
||||||
|
<div class='span6'>
|
||||||
|
<table class='table'>
|
||||||
<colgroup>
|
<colgroup>
|
||||||
<col class='col-label' />
|
<col class='col-label' />
|
||||||
<col class='col-control' />
|
<col class='col-control' />
|
||||||
@@ -1060,30 +1062,34 @@ class media_admin_ui extends e_admin_ui
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Margin-Left: </td>
|
<td>Margin-Left: </td>
|
||||||
<td><input class='e-media-attribute' type='text' id='margin-left' name='margin_left' value='' /></td>
|
<td><input class='e-media-attribute input-mini' type='text' id='margin-left' name='margin_left' value='' /> px</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Margin-Right: </td>
|
<td>Margin-Right: </td>
|
||||||
<td><input class='e-media-attribute' type='text' id='margin-right' name='margin_right' value='' /></td>
|
<td><input class='e-media-attribute input-mini' type='text' id='margin-right' name='margin_right' value='' /> px</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Margin-Top: </td>
|
<td>Margin-Top: </td>
|
||||||
<td><input class='e-media-attribute' type='text' id='margin-top' name='margin_top' value='' /></td>
|
<td><input class='e-media-attribute input-mini' type='text' id='margin-top' name='margin_top' value='' /> px</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Margin-Bottom: </td>
|
<td>Margin-Bottom: </td>
|
||||||
<td><input class='e-media-attribute' type='text' id='margin-bottom' name='margin_bottom' value='' /></td>
|
<td><input class='e-media-attribute input-mini' type='text' id='margin-bottom' name='margin_bottom' value='' /> px</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</tbody></table>
|
</tbody></table>
|
||||||
<table><tr><td>Preview<br /></td></tr>
|
</div>
|
||||||
<tr><td style='text-align:center'>
|
<div class='span6'>
|
||||||
<img id='preview' src='".e_IMAGE_ABS."generic/blank.gif' style='border:1px solid silver; min-width:220px; min-height:180px;' />
|
<h5>Preview</h5>
|
||||||
|
|
||||||
|
<img class='well' id='preview' src='".e_IMAGE_ABS."generic/blank.gif' style='min-width:220px; min-height:180px;' />
|
||||||
|
|
||||||
</td></tr></table>
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>";
|
</div>";
|
||||||
}
|
}
|
||||||
$text .= "</div>";
|
$text .= "</div>";
|
||||||
|
@@ -509,14 +509,14 @@ class e_media
|
|||||||
{
|
{
|
||||||
parse_str($att,$option);
|
parse_str($att,$option);
|
||||||
|
|
||||||
$cat = ($category) ? '&for='.$category : "";
|
$cat = varset($category) ? '&for='.$category : "";
|
||||||
|
|
||||||
if(!$label) $label = ' Upload an image or file';
|
// if(!$label) $label = ' Upload an image or file';
|
||||||
if($option['tagid']) $cat .= '&tagid='.$option['tagid'];
|
if(varset($option['tagid'])) $cat .= '&tagid='.$option['tagid'];
|
||||||
if($option['bbcode']) $cat .= '&bbcode='.$option['bbcode'];
|
if(varset($option['bbcode'])) $cat .= '&bbcode='.$option['bbcode'];
|
||||||
|
|
||||||
$cat .= ($option['limit']) ? "&limit=".$option['limit'] : "";
|
$cat .= varset($option['limit']) ? "&limit=".$option['limit'] : "";
|
||||||
$cat .= ($option['frm']) ? "&frm=".$option['frm'] : "";
|
$cat .= varset($option['frm']) ? "&frm=".$option['frm'] : "";
|
||||||
|
|
||||||
$url = e_ADMIN_ABS."image.php?mode=main&action=nav&iframe=1".$cat;
|
$url = e_ADMIN_ABS."image.php?mode=main&action=nav&iframe=1".$cat;
|
||||||
return $url;
|
return $url;
|
||||||
@@ -535,12 +535,12 @@ class e_media
|
|||||||
$option = $att;
|
$option = $att;
|
||||||
}
|
}
|
||||||
|
|
||||||
$frm = ($option['from']) ? $option['from'] : 0;
|
$frm = varset($option['from']) ? $option['from'] : 0;
|
||||||
$limit = ($option['limit']) ? $option['limit'] : 20;
|
$limit = varset($option['limit']) ? $option['limit'] : 20;
|
||||||
$newfrm = $frm + $limit;
|
$newfrm = $frm + $limit;
|
||||||
$bbcode = ($option['bbcode']) ? $option['bbcode'] : null;
|
$bbcode = varset($option['bbcode']) ? $option['bbcode'] : null;
|
||||||
$navMode = ($option['nav']) ? TRUE : FALSE;
|
$navMode = varset($option['nav']) ? TRUE : FALSE;
|
||||||
$search = ($option['search']) ? $option['search'] : null;
|
$search = varset($option['search']) ? $option['search'] : null;
|
||||||
|
|
||||||
if($category !='_icon')
|
if($category !='_icon')
|
||||||
{
|
{
|
||||||
@@ -572,7 +572,7 @@ class e_media
|
|||||||
$thumbAtt = 'aw=120&ah=100'; // Thumbnail of the Media-Manager Preview.
|
$thumbAtt = 'aw=120&ah=100'; // Thumbnail of the Media-Manager Preview.
|
||||||
|
|
||||||
// EXAMPLE of FILTER GUI.
|
// EXAMPLE of FILTER GUI.
|
||||||
// $text .= "CAT=".$cat;
|
$text = "";
|
||||||
$dipTotal = (($frm + $limit) < $total) ? ($frm + $limit) : $total;
|
$dipTotal = (($frm + $limit) < $total) ? ($frm + $limit) : $total;
|
||||||
|
|
||||||
if($navMode === false)
|
if($navMode === false)
|
||||||
@@ -603,7 +603,7 @@ class e_media
|
|||||||
parent.document.getElementById('".$prevId."').src = '".e_IMAGE_ABS."generic/blank.gif';
|
parent.document.getElementById('".$prevId."').src = '".e_IMAGE_ABS."generic/blank.gif';
|
||||||
return false;";
|
return false;";
|
||||||
|
|
||||||
$text .= "<a class='{$class} media-select-none e-dialog-close' data-src='{$im['media_url']}' style='vertical-align:middle;display:block;float:left;' href='#' onclick=\"{$onclick_clear}\" >
|
$text .= "<a class='{$class} media-select-none e-dialog-close' data-src='".varset($im['media_url'])."' style='vertical-align:middle;display:block;float:left;' href='#' onclick=\"{$onclick_clear}\" >
|
||||||
<div style='text-align:center;position: relative; top: 30%'>No image</div>
|
<div style='text-align:center;position: relative; top: 30%'>No image</div>
|
||||||
</a>";
|
</a>";
|
||||||
}
|
}
|
||||||
@@ -649,7 +649,7 @@ class e_media
|
|||||||
|
|
||||||
$realPath = $tp->thumbUrl($im['media_url'], $prevAtt); // Parsed back to Form as Preview Image.
|
$realPath = $tp->thumbUrl($im['media_url'], $prevAtt); // Parsed back to Form as Preview Image.
|
||||||
|
|
||||||
$diz = $tp->toAttribute($im['media_title'])."\n".$im['media_dimensions'];
|
$diz = $tp->toAttribute(varset($im['media_title']))."\n".varset($im['media_dimensions']);
|
||||||
$repl = array($im['media_url'],$media_path);
|
$repl = array($im['media_url'],$media_path);
|
||||||
|
|
||||||
if($bbcode == null) // e107 Media Manager
|
if($bbcode == null) // e107 Media Manager
|
||||||
|
@@ -80,10 +80,11 @@ if($_POST['mode'] == 'tobbcode')
|
|||||||
|
|
||||||
// resize the thumbnail to match wysiwyg width/height.
|
// 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';
|
// $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" ';
|
// $prepl = '<img src="{e_BASE}thumb.php?src=$1w=$5&h=$6"$4width="$5" height="$6" ';
|
||||||
|
|
||||||
$content = preg_replace($psrch, $prepl, $content);
|
// $content = preg_replace($psrch, $prepl, $content);
|
||||||
|
$content = updateImg($content);
|
||||||
$content = $tp->parseBBTags($content,true); // replace html with bbcode equivalent
|
$content = $tp->parseBBTags($content,true); // replace html with bbcode equivalent
|
||||||
|
|
||||||
echo ($content) ? "[html]".$content."[/html]" : ""; // Add the tags before saving to DB.
|
echo ($content) ? "[html]".$content."[/html]" : ""; // Add the tags before saving to DB.
|
||||||
@@ -98,6 +99,45 @@ if($_POST['mode'] == 'tobbcode')
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rebuld <img> tags with modified thumbnail size.
|
||||||
|
*/
|
||||||
|
function updateImg($text)
|
||||||
|
{
|
||||||
|
|
||||||
|
$arr = e107::getParser()->getTags($text,'img');
|
||||||
|
|
||||||
|
$srch = array("?","&");
|
||||||
|
$repl = array("\?","&");
|
||||||
|
|
||||||
|
foreach($arr['img'] as $img)
|
||||||
|
{
|
||||||
|
$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'].'"' : '';
|
||||||
|
$class = vartrue($img['class']) ? ' class="'.$img['class'].'"' : '';
|
||||||
|
$alt = vartrue($img['alt']) ? ' alt="'.$img['alt'].'"' : '';
|
||||||
|
|
||||||
|
list($url,$qry) = explode("?",$img['src']);
|
||||||
|
|
||||||
|
parse_str($qry,$qr);
|
||||||
|
|
||||||
|
$qr['w'] = $img['width'];
|
||||||
|
$qr['h'] = $img['height'];
|
||||||
|
|
||||||
|
$src = $url."?".urldecode(http_build_query($qr));
|
||||||
|
|
||||||
|
$replacement = '<img'.$class.$style.' src="'.$src.'"'.$width.$height.$alt.' />';
|
||||||
|
|
||||||
|
$text = preg_replace($regexp, $replacement, $text);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $text;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
@@ -85,10 +85,13 @@ $(document).ready(function()
|
|||||||
style = style + 'float:' + _float + ';';
|
style = style + 'float:' + _float + ';';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Set the Html / Wysiwyg Value.
|
// Set the Html / Wysiwyg Value.
|
||||||
var html = '<img class="img-rounded" style=\"' + style + '\" src=\"'+ src +'\" alt=\"\" width=\"' + width + '\" height=\"' + height + '\" />';
|
var html = '<img class="img-rounded" style=\"' + style + '\" src=\"'+ src +'\" alt=\"\" width=\"' + width + '\" height=\"' + height + '\" />';
|
||||||
$('#html_holder').val(html);
|
$('#html_holder').val(html);
|
||||||
|
|
||||||
|
|
||||||
// Only Do width/height styling on bbcodes --
|
// Only Do width/height styling on bbcodes --
|
||||||
if(width !='')
|
if(width !='')
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user