Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2916406
D25862.1737483751.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
3 KB
Referenced Files
None
Subscribers
None
D25862.1737483751.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
@@ -7,6 +7,8 @@
private $image;
private $imageX;
private $imageY;
+ const MAX_TRANSFORM_WIDTH = 4096; /* int */
+ const MAX_TRANSFORM_HEIGHT = 4096; /* int */
/**
* Get an estimate of the transformed dimensions of a file.
@@ -334,7 +336,7 @@
'Unable to determine image width and height with getimagesize().'));
}
- $max_pixels = (4096 * 4096);
+ $max_pixels = (self::MAX_TRANSFORM_WIDTH * self::MAX_TRANSFORM_HEIGHT);
$img_pixels = ($width * $height);
if ($img_pixels > $max_pixels) {
@@ -365,6 +367,14 @@
return $this->image;
}
+ /**
+ * Get maximum supported image dimensions in pixels for transforming
+ * @return array<int> Maximum width and height
+ */
+ public static function getMaxTransformDimensions() {
+ return array(self::MAX_TRANSFORM_WIDTH, self::MAX_TRANSFORM_HEIGHT);
+ }
+
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,11 @@
$e_file = true;
$errors = array();
+ $max_image_dimensions =
+ PhabricatorFileImageTransform::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;
@@ -254,7 +259,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,11 @@
$e_file = true;
$errors = array();
+ $max_image_dimensions =
+ PhabricatorFileImageTransform::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;
@@ -261,7 +266,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
Tue, Jan 21, 18:22 (1 d, 2 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1134128
Default Alt Text
D25862.1737483751.diff (3 KB)
Attached To
Mode
D25862: Communicate max dimensions of profile images before upload
Attached
Detach File
Event Timeline
Log In to Comment