Index: branches/5.2.x/core/units/helpers/image_helper.php =================================================================== --- branches/5.2.x/core/units/helpers/image_helper.php +++ branches/5.2.x/core/units/helpers/image_helper.php @@ -112,7 +112,7 @@ throw new RuntimeException(sprintf('Image "%s" doesn\'t exist', $src_image)); } - if ($params['max_width'] > 0 || $params['max_height'] > 0) { + if ( !$this->isSVG($src_image) && ($params['max_width'] > 0 || $params['max_height'] > 0) ) { list ($params['target_width'], $params['target_height'], $needs_resize) = $this->GetImageDimensions($src_image, $params['max_width'], $params['max_height'], $params); if (!is_numeric($params['max_width'])) { @@ -158,8 +158,12 @@ } } - if ($image_size) { - // return only image size (resized or not) + if ( $image_size ) { + if ( $this->isSVG($src_image) ) { + return 'width="' . $params['max_width'] . '" height="' . $params['max_height'] . '"'; + } + + // Return only image size (resized or not). $image_info = $this->getImageInfo($src_image); return $image_info ? $image_info[3] : ''; } @@ -443,6 +447,11 @@ */ function GetImageDimensions($src_image, $dst_width, $dst_height, $params) { + // The SVG file is in vector format and can scale to any size. + if ( $this->isSVG($src_image) ) { + return array($dst_width, $dst_height, false); + } + $image_info = $this->getImageInfo($src_image); if (!$image_info) { return false; @@ -513,7 +522,7 @@ */ function getImageInfo($src_image) { - if (!file_exists($src_image)) { + if ( !file_exists($src_image) || $this->isSVG($src_image) ) { return false; } @@ -527,6 +536,18 @@ } /** + * Checks if image is an SVG file. + * + * @param string $src_image Full path to source image (already existing). + * + * @return boolean + */ + protected function isSVG($src_image) + { + return pathinfo($src_image, PATHINFO_EXTENSION) == 'svg'; + } + + /** * Returns maximal image size (width & height) among fields specified * * @param kDBItem $object