Index: branches/RC/core/units/general/helpers/image_helper.php =================================================================== diff -u -N -r9176 -r9252 --- branches/RC/core/units/general/helpers/image_helper.php (.../image_helper.php) (revision 9176) +++ branches/RC/core/units/general/helpers/image_helper.php (.../image_helper.php) (revision 9252) @@ -113,6 +113,49 @@ } /** + * Returns maximal image size (width & height) among fields specified + * + * @param kDBItem $object + * @param string $fields + * @param string $format any format, that returns full url (e.g. files_resized:WxH, resize:WxH, full_url, full_urls) + * @return string + */ + function MaxImageSize(&$object, $fields, $format = null) + { + static $cached_sizes = Array (); + + $cache_key = $object->getPrefixSpecial().'_'.$object->GetID(); + if (!isset($cached_sizes[$cache_key])) { + $images = Array (); + + $fields = explode(',', $fields); + foreach ($fields as $field) { + $image_data = $object->GetField($field, $format); + if (!$image_data) { + continue; + } + + $images = array_merge($images, explode('|', $image_data)); + } + + $max_width = 0; + $max_height = 0; + $base_url = rtrim($this->Application->BaseURL(), '/'); + + foreach ($images as $image_url) { + $image_path = preg_replace('/^'.preg_quote($base_url, '/').'(.*)/', FULL_PATH.'\\1', $image_url); + $image_info = $this->getImageInfo($image_path); + $max_width = max($max_width, $image_info[0]); + $max_height = max($max_height, $image_info[1]); + } + + $cached_sizes[$cache_key] = Array ($max_width, $max_height); + } + + return $cached_sizes[$cache_key]; + } + + /** * Determines what image fields should be created (from post or just dummy fields for 1st upload) * * @param string $prefix