Index: branches/5.2.x/core/kernel/utility/formatters/upload_formatter.php =================================================================== diff -u -N -r15345 -r15346 --- branches/5.2.x/core/kernel/utility/formatters/upload_formatter.php (.../upload_formatter.php) (revision 15345) +++ branches/5.2.x/core/kernel/utility/formatters/upload_formatter.php (.../upload_formatter.php) (revision 15346) @@ -1,6 +1,6 @@ GetFieldOptions($field_name); - $upload_dir = isset($options['upload_dir']) ? $options['upload_dir'] : $this->DestinationPath; + $upload_dir = isset($options['include_path']) && $options['include_path'] ? '' : $this->getUploadDir($options); if (preg_match('/resize:([\d]*)x([\d]*)/', $format, $regs)) { $image_helper = $this->Application->recallObject('ImageHelper'); /* @var $image_helper ImageHelper */ - if (array_key_exists('include_path', $options) && $options['include_path']) { - // relative path is already included in field - $upload_dir = ''; - } - return $image_helper->ResizeImage($value ? FULL_PATH . str_replace('/', DIRECTORY_SEPARATOR, $upload_dir) . $value : '', $format); } @@ -450,6 +445,11 @@ return str_replace($replace_from, $replace_to, $option); } + + public function getUploadDir($options) + { + return isset($options['upload_dir']) ? $options['upload_dir'] : $this->DestinationPath; + } } class kPictureFormatter extends kUploadFormatter @@ -462,14 +462,24 @@ parent::__construct(); } - function GetFormatted($value, $field_name, &$object, $format = null, $force_direct_links = null) + /** + * Return formatted file url,path or size + * + * @param string $value + * @param string $field_name + * @param kDBItem $object + * @param string $format + * @param bool $force_direct_links + * @return string + */ + function GetFormatted($value, $field_name, &$object, $format = NULL, $force_direct_links = NULL) { - if ($format == 'img_size') { - $upload_dir = isset($options['upload_dir']) ? $options['upload_dir'] : $this->DestinationPath; - $img_path = FULL_PATH.'/'.$upload_dir.$value; + if ( $format == 'img_size' ) { + $options = $object->GetFieldOptions($field_name); + $img_path = FULL_PATH . '/' . $this->getUploadDir($options) . $value; + $image_info = getimagesize($img_path); - $image_info = @getimagesize($img_path); - return ' width="'.$image_info[0].'" height="'.$image_info[1].'"'; + return ' ' . $image_info[3]; } return parent::GetFormatted($value, $field_name, $object, $format, $force_direct_links);