Index: trunk/kernel/units/images/image_tag_processor.php =================================================================== diff -u -N -r8391 -r8472 --- trunk/kernel/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8391) +++ trunk/kernel/units/images/image_tag_processor.php (.../image_tag_processor.php) (revision 8472) @@ -15,13 +15,13 @@ if (!$image_url) { return ; } - + $block_params['img_path'] = $image_url; $image_dimensions = $this->ImageSize($block_params); $block_params['img_size'] = $image_dimensions ? $image_dimensions : ' width="'.$block_params['DefaultWidth'].'"'; $block_params['alt'] = htmlspecialchars($object->GetField('AltName')); // really used ? } - + /** * [AGGREGATED TAG] works as * @@ -62,10 +62,10 @@ function LoadItemImage($params) { $parent_item =& $this->Application->recallObject($params['PrefixSpecial']); - + $object =& $this->Application->recallObject($this->getPrefixSpecial(), null, Array('skip_autoload' => true)); /* @var $object kDBItem */ - + $object->Clear(); // if we need primary thumbnail which is preloaded with products list @@ -116,9 +116,9 @@ function ImageSrc($params) { $object =& $this->getObject($params); - + $base_url = rtrim($this->Application->BaseURL(), '/'); - + $ret = ''; // if we need thumb, or full image is same as thumb if ( $this->SelectParam($params, 'thumbnail,Thumbnail') || $object->GetDBField('SameImages') ) @@ -169,38 +169,15 @@ { $img_path = $this->getFullPath($params['img_path']); - if (!file_exists($img_path)) { + $image_helper =& $this->Application->recallObject('ImageHelper'); + /* @var $image_helper ImageHelper */ + + $image_dimensions = $image_helper->GetImageDimensions($img_path, getArrayValue($params, 'MaxWidth'), getArrayValue($params, 'MaxHeight')); + if (!$image_dimensions) { return false; } - - $image_info = @getimagesize($img_path); - if (!$image_info) { - trigger_error('Image '.$img_path.' missing or invalid', E_USER_WARNING); - return false; - } - $orig_width = getArrayValue($image_info, 0); - $orig_height = getArrayValue($image_info, 1); - $max_width = getArrayValue($params, 'MaxWidth'); - $max_height = getArrayValue($params, 'MaxHeight'); - - $too_large = is_numeric($max_width) ? ($orig_width > $max_width) : false; - $too_large = $too_large || (is_numeric($max_height) ? ($orig_height > $max_height) : false); - - if ($too_large) { - $width_ratio = $max_width ? $max_width / $orig_width : 1; - $height_ratio = $max_height ? $max_height / $orig_height : 1; - $ratio = min($width_ratio, $height_ratio); - - $width = ceil($orig_width * $ratio); - $height = ceil($orig_height * $ratio); - } - else { - $width = $orig_width; - $height = $orig_height; - } - - return ' width="'.$width.'" height="'.$height.'"'; + return ' width="'.$image_dimensions[0].'" height="'.$image_dimensions[1].'"'; } /** @@ -215,7 +192,7 @@ if (!$image_url) { return ; } - + $object =& $this->getObject($params); $params['img_path'] = $image_url; $image_dimensions = $this->ImageSize($params); @@ -225,8 +202,8 @@ return $this->Application->ParseBlock($params); } - - + + /** * Returns url for image in case when image source is url (for admin) *