Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2929759
D25862.1737665061.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
4 KB
Referenced Files
None
Subscribers
None
D25862.1737665061.diff
View Options
diff --git a/src/applications/files/transform/PhabricatorFileImageTransform.php b/src/applications/files/transform/PhabricatorFileImageTransform.php
--- a/src/applications/files/transform/PhabricatorFileImageTransform.php
+++ b/src/applications/files/transform/PhabricatorFileImageTransform.php
@@ -334,7 +334,8 @@
'Unable to determine image width and height with getimagesize().'));
}
- $max_pixels = (4096 * 4096);
+ $max_pixels_array = $this->getMaxTransformDimensions();
+ $max_pixels = ($max_pixels_array[0] * $max_pixels_array[1]);
$img_pixels = ($width * $height);
if ($img_pixels > $max_pixels) {
@@ -365,6 +366,15 @@
return $this->image;
}
+ /**
+ * Get maximum supported image dimensions in pixels for transforming
+ *
+ * @return array<int> Maximum width and height
+ */
+ public function getMaxTransformDimensions() {
+ return array(4096, 4096);
+ }
+
private function shouldUseImagemagick() {
if (!PhabricatorEnv::getEnvConfig('files.enable-imagemagick')) {
return false;
diff --git a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
--- a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
+++ b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php
@@ -36,6 +36,15 @@
$e_file = true;
$errors = array();
+ // Get the image file transform.
+ $xform = PhabricatorFileTransform::getTransformByKey(
+ PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
+
+ // Have an hard-limit to save our resources.
+ $max_image_dimensions = $xform->getMaxTransformDimensions();
+ $max_image_dimensions_message = pht('Maximum image dimensions: %s pixels.',
+ implode(mb_chr(215), $max_image_dimensions));
+
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
@@ -67,8 +76,6 @@
$e_file = pht('Not Supported');
$errors[] = $supported_formats_message;
} else {
- $xform = PhabricatorFileTransform::getTransformByKey(
- PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
$xformed = $xform->executeTransform($file);
}
}
@@ -254,7 +261,8 @@
->setName('picture')
->setLabel(pht('Upload Picture'))
->setError($e_file)
- ->setCaption($supported_formats_message))
+ ->setCaption($supported_formats_message.' '.
+ $max_image_dimensions_message))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($done_uri)
diff --git a/src/applications/project/controller/PhabricatorProjectEditPictureController.php b/src/applications/project/controller/PhabricatorProjectEditPictureController.php
--- a/src/applications/project/controller/PhabricatorProjectEditPictureController.php
+++ b/src/applications/project/controller/PhabricatorProjectEditPictureController.php
@@ -35,6 +35,15 @@
$e_file = true;
$errors = array();
+ // Get the image file transform.
+ $xform = PhabricatorFileTransform::getTransformByKey(
+ PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
+
+ // Have an hard-limit to save our resources.
+ $max_image_dimensions = $xform->getMaxTransformDimensions();
+ $max_image_dimensions_message = pht('Maximum image dimensions: %s pixels.',
+ implode(mb_chr(215), $max_image_dimensions));
+
if ($request->isFormPost()) {
$phid = $request->getStr('phid');
$is_default = false;
@@ -66,8 +75,6 @@
$e_file = pht('Not Supported');
$errors[] = $supported_formats_message;
} else {
- $xform = PhabricatorFileTransform::getTransformByKey(
- PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
$xformed = $xform->executeTransform($file);
}
}
@@ -261,7 +268,8 @@
->setName('picture')
->setLabel(pht('Upload Picture'))
->setError($e_file)
- ->setCaption($supported_formats_message))
+ ->setCaption($supported_formats_message.' '.
+ $max_image_dimensions_message))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($manage_uri)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 23, 20:44 (21 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1146320
Default Alt Text
D25862.1737665061.diff (4 KB)
Attached To
Mode
D25862: Communicate max dimensions of profile images before upload
Attached
Detach File
Event Timeline
Log In to Comment