Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14033258
D12809.id30828.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12809.id30828.diff
View Options
diff --git a/resources/builtin/image-100x100.png b/resources/builtin/image-100x100.png
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
diff --git a/resources/builtin/image-220x220.png b/resources/builtin/image-220x220.png
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
diff --git a/resources/builtin/image-280x210.png b/resources/builtin/image-280x210.png
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
diff --git a/src/applications/files/controller/PhabricatorFileTransformController.php b/src/applications/files/controller/PhabricatorFileTransformController.php
--- a/src/applications/files/controller/PhabricatorFileTransformController.php
+++ b/src/applications/files/controller/PhabricatorFileTransformController.php
@@ -54,7 +54,18 @@
if (isset($xforms[$transform])) {
$xform = $xforms[$transform];
if ($xform->canApplyTransform($file)) {
- $xformed_file = $xforms[$transform]->applyTransform($file);
+ try {
+ $xformed_file = $xforms[$transform]->applyTransform($file);
+ } catch (Exception $ex) {
+ // TODO: Provide a diagnostic mode to surface these to the viewer.
+
+ // In normal transform mode, we ignore failures and generate a
+ // default transform instead.
+ }
+ }
+
+ if (!$xformed_file) {
+ $xformed_file = $xform->getDefaultTransform($file);
}
}
diff --git a/src/applications/files/transform/PhabricatorFileThumbnailTransform.php b/src/applications/files/transform/PhabricatorFileThumbnailTransform.php
--- a/src/applications/files/transform/PhabricatorFileThumbnailTransform.php
+++ b/src/applications/files/transform/PhabricatorFileThumbnailTransform.php
@@ -71,4 +71,20 @@
}
}
+ public function getDefaultTransform(PhabricatorFile $file) {
+ $x = (int)$this->dstX;
+ $y = (int)$this->dstY;
+ $name = 'image-'.$x.'x'.nonempty($y, $x).'.png';
+
+ $params = array(
+ 'name' => $name,
+ 'canCDN' => true,
+ );
+
+ $root = dirname(phutil_get_library_root('phabricator'));
+ $data = Filesystem::readFile($root.'/resources/builtin/'.$name);
+
+ return PhabricatorFile::newFromFileData($data, $params);
+ }
+
}
diff --git a/src/applications/files/transform/PhabricatorFileTransform.php b/src/applications/files/transform/PhabricatorFileTransform.php
--- a/src/applications/files/transform/PhabricatorFileTransform.php
+++ b/src/applications/files/transform/PhabricatorFileTransform.php
@@ -7,6 +7,10 @@
abstract public function canApplyTransform(PhabricatorFile $file);
abstract public function applyTransform(PhabricatorFile $file);
+ public function getDefaultTransform(PhabricatorFile $file) {
+ return null;
+ }
+
public function generateTransforms() {
return array($this);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 10, 5:12 PM (1 w, 16 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6731464
Default Alt Text
D12809.id30828.diff (3 KB)
Attached To
Mode
D12809: Make modular transforms handle exceptions gracefully
Attached
Detach File
Event Timeline
Log In to Comment