From 4bc7f70dbdc31c5ad5eb0aebada5482575778c59 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Mon, 22 Aug 2011 23:52:45 +0000 Subject: [PATCH] Image-preview path fix. Resize-on-Import added to Media-manager. --- e107_admin/image.php | 47 +++++++++++++++++++++++++++++++-- e107_handlers/e_parse_class.php | 4 ++- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/e107_admin/image.php b/e107_admin/image.php index 1567f2417..276552860 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -225,6 +225,8 @@ class media_admin_ui extends e_admin_ui protected $pid = "media_id"; protected $perPage = 10; 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 /* @@ -596,6 +598,7 @@ class media_admin_ui extends e_admin_ui $mes = e107::getMessage(); $sql = e107::getDb(); $tp = e107::getParser(); + if(!count($_POST['batch_selected'])) { @@ -603,10 +606,32 @@ class media_admin_ui extends e_admin_ui return; } + + 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) { + $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); @@ -883,6 +908,11 @@ if (isset($_POST['update_options'])) $tmp['image_post_class'] = intval($_POST['image_post_class']); $tmp['image_post_disabled_method'] = intval($_POST['image_post_disabled_method']); $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')) { @@ -1233,7 +1263,7 @@ if (isset($_POST['check_avatar_sizes'])) } $text = " -
+
".IMALAN_7." @@ -1274,6 +1304,18 @@ if (isset($_POST['check_avatar_sizes'])) ".$frm->select_close()."
".IMALAN_13."
+ "; + + list($img_import_w,$img_import_h) = explode("x",$pref['img_import_resize']); + + //TODO LANS + $text .= " + + + @@ -1294,7 +1336,8 @@ if (isset($_POST['check_avatar_sizes'])) ".$frm->text('im_path', $pref['im_path'])."
".IMALAN_6."
- + +
Resize images during media import
Leave empty to disable
+ ".$frm->text('img_import_resize_w', $img_import_w,4)."px X ".$frm->text('img_import_resize_h', $img_import_h,4)."px +
".IMALAN_6."
+
".IMALAN_34." diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 9db7ada0b..b652d2d1f 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -1757,7 +1757,7 @@ class e_parse { 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)) @@ -1766,6 +1766,8 @@ class e_parse } if($raw) $url = $this->createConstants($url, 'mix'); + + // echo "
".$url; $thurl = ($full ? SITEURL : e_HTTP).'thumb.php?src='.$url.'&';