1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-27 18:00:30 +02:00

Image-preview path fix. Resize-on-Import added to Media-manager.

This commit is contained in:
CaMer0n
2011-08-22 23:52:45 +00:00
parent 897192893c
commit 4bc7f70dbd
2 changed files with 48 additions and 3 deletions

View File

@@ -225,6 +225,8 @@ class media_admin_ui extends e_admin_ui
protected $pid = "media_id"; protected $pid = "media_id";
protected $perPage = 10; protected $perPage = 10;
protected $batchDelete = true; protected $batchDelete = true;
// protected $defaultOrder = 'desc';
protected $listOrder = 'm.media_id desc'; // show newest images first.
//TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields //TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields
/* /*
@@ -597,6 +599,7 @@ class media_admin_ui extends e_admin_ui
$sql = e107::getDb(); $sql = e107::getDb();
$tp = e107::getParser(); $tp = e107::getParser();
if(!count($_POST['batch_selected'])) if(!count($_POST['batch_selected']))
{ {
$mes->addError("Please check at least one image."); $mes->addError("Please check at least one image.");
@@ -604,10 +607,32 @@ class media_admin_ui extends e_admin_ui
} }
require(e_HANDLER.'phpthumb/ThumbLib.inc.php'); // For resizing on import.
list($img_import_w,$img_import_h) = explode("x",e107::getPref('img_import_resize'));
foreach($_POST['batch_selected'] as $file) foreach($_POST['batch_selected'] as $file)
{ {
$oldpath = e_MEDIA."temp/".$file; $oldpath = e_MEDIA."temp/".$file;
// Resize on Import Routine ------------------------
if(vartrue($img_import_w) && vartrue($img_import_h))
{
try
{
$thumb = PhpThumbFactory::create($oldpath);
$thumb->setOptions(array('correctPermissions' => true));
}
catch (Exception $e)
{
$mes->addError($e->getMessage());
// return $this;
}
$thumb->resize($img_import_w,$img_import_h)->save($oldpath);
}
// End Resize routine. ---------------------
$f = $fl->get_file_info($oldpath); $f = $fl->get_file_info($oldpath);
if(!$f['mime']) if(!$f['mime'])
@@ -884,6 +909,11 @@ if (isset($_POST['update_options']))
$tmp['image_post_disabled_method'] = intval($_POST['image_post_disabled_method']); $tmp['image_post_disabled_method'] = intval($_POST['image_post_disabled_method']);
$tmp['enable_png_image_fix'] = intval($_POST['enable_png_image_fix']); $tmp['enable_png_image_fix'] = intval($_POST['enable_png_image_fix']);
if($_POST['img_import_resize_w'] && $_POST['img_import_resize_h'])
{
$tmp['img_import_resize'] = intval($_POST['img_import_resize_w'])."x".intval($_POST['img_import_resize_h']);
}
if ($admin_log->logArrayDiffs($tmp, $pref, 'IMALAN_04')) if ($admin_log->logArrayDiffs($tmp, $pref, 'IMALAN_04'))
{ {
save_prefs(); // Only save if changes save_prefs(); // Only save if changes
@@ -1233,7 +1263,7 @@ if (isset($_POST['check_avatar_sizes']))
} }
$text = " $text = "
<form method='post' action='".e_SELF."'> <form method='post' action='".e_SELF."?".e_QUERY."'>
<fieldset id='core-image-settings'> <fieldset id='core-image-settings'>
<legend class='e-hideme'>".IMALAN_7."</legend> <legend class='e-hideme'>".IMALAN_7."</legend>
<table cellpadding='0' cellspacing='0' class='adminform'> <table cellpadding='0' cellspacing='0' class='adminform'>
@@ -1274,6 +1304,18 @@ if (isset($_POST['check_avatar_sizes']))
".$frm->select_close()." ".$frm->select_close()."
<div class='field-help'>".IMALAN_13."</div> <div class='field-help'>".IMALAN_13."</div>
</td> </td>
</tr>";
list($img_import_w,$img_import_h) = explode("x",$pref['img_import_resize']);
//TODO LANS
$text .= "
<tr>
<td class='label'>Resize images during media import<div class='label-note'>Leave empty to disable</div></td>
<td class='control'>
".$frm->text('img_import_resize_w', $img_import_w,4)."px X ".$frm->text('img_import_resize_h', $img_import_h,4)."px
<div class='field-help'>".IMALAN_6."</div>
</td>
</tr> </tr>
<tr> <tr>
@@ -1296,6 +1338,7 @@ if (isset($_POST['check_avatar_sizes']))
</td> </td>
</tr> </tr>
<tr> <tr>
<td class='label'>".IMALAN_34." <td class='label'>".IMALAN_34."
</td> </td>

View File

@@ -1757,7 +1757,7 @@ class e_parse
{ {
if(substr($url,0,3)=="{e_") // Fix for broken links that use {e_MEDIA} etc. if(substr($url,0,3)=="{e_") // Fix for broken links that use {e_MEDIA} etc.
{ {
$url = $this->replaceConstants($url); $url = $this->replaceConstants($url,'abs');
} }
if(!is_array($options)) if(!is_array($options))
@@ -1767,6 +1767,8 @@ class e_parse
if($raw) $url = $this->createConstants($url, 'mix'); if($raw) $url = $this->createConstants($url, 'mix');
// echo "<br />".$url;
$thurl = ($full ? SITEURL : e_HTTP).'thumb.php?src='.$url.'&amp;'; $thurl = ($full ? SITEURL : e_HTTP).'thumb.php?src='.$url.'&amp;';
if(vartrue($options['aw']) || vartrue($options['ah'])) if(vartrue($options['aw']) || vartrue($options['ah']))