Index: branches/RC/core/kernel/utility/formatters/upload_formatter.php =================================================================== diff -u -r9249 -r9250 --- branches/RC/core/kernel/utility/formatters/upload_formatter.php (.../upload_formatter.php) (revision 9249) +++ branches/RC/core/kernel/utility/formatters/upload_formatter.php (.../upload_formatter.php) (revision 9250) @@ -185,6 +185,10 @@ if (isset($options['format'])) { $upload_dir = isset($options['upload_dir']) ? $options['upload_dir'] : $this->DestinationPath; + if (preg_match('/resize:([\d]*)x([\d]*)/', $options['format'], $regs)) { + return $this->resizeImage(FULL_PATH.$upload_dir.$tc_value, $regs[1], $regs[2]); + } + switch ($options['format']) { case 'full_url': return rtrim($this->Application->BaseURL(), '/').$upload_dir.$tc_value; @@ -203,6 +207,35 @@ return $tc_value; } + function resizeImage($src_image, $max_width, $max_height) + { + if ($max_width > 0 || $max_height > 0) { + $image_helper =& $this->Application->recallObject('ImageHelper'); + /* @var $image_helper ImageHelper */ + + list ($max_width, $max_height, $resized) = $image_helper->GetImageDimensions($src_image, $max_width, $max_height); + + if ($resized) { + $src_path = dirname($src_image); + $dst_image = preg_replace('/^'.preg_quote($src_path, '/').'(.*)\.(.*)$/', $src_path.'/resized\\1_'.$max_width.'x'.$max_height.'.\\2', $src_image); + if (!file_exists($dst_image) || filemtime($src_image) > filemtime($dst_image)) { + // resized image not available OR should be recreated due source image change + $image_resized = $image_helper->ScaleImage($src_image, $dst_image, $max_width, $max_height); + if (!$image_resized) { + // resize failed, because of server error + $dst_image = $src_image; + } + } + + // resize ok + $src_image = $dst_image; + } + } + + $base_url = rtrim($this->Application->BaseURL(), '/'); + return preg_replace('/^'.preg_quote(FULL_PATH, '/').'(.*)/', $base_url.'\\1', $src_image); + } + function ValidateFileName($path, $name) { $parts = pathinfo($name);