Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1046760
D268.id659.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jun 29, 3:57 AM
Size
2 KB
Mime Type
text/x-diff
Expires
Mon, Jun 30, 3:57 AM (5 h, 4 m)
Engine
blob
Format
Raw Data
Handle
676748
Attached To
D268: INP-1656 - Emulate SVG file resize in "ImageHelper"
D268.id659.diff
View Options
Index: core/units/helpers/image_helper.php
===================================================================
--- core/units/helpers/image_helper.php
+++ 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
Event Timeline
Log In to Comment