Differential D12809 Diff 30828 src/applications/files/controller/PhabricatorFileTransformController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/controller/PhabricatorFileTransformController.php
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); | ||||
| $xformed_file = null; | $xformed_file = null; | ||||
| $xforms = PhabricatorFileTransform::getAllTransforms(); | $xforms = PhabricatorFileTransform::getAllTransforms(); | ||||
| if (isset($xforms[$transform])) { | if (isset($xforms[$transform])) { | ||||
| $xform = $xforms[$transform]; | $xform = $xforms[$transform]; | ||||
| if ($xform->canApplyTransform($file)) { | if ($xform->canApplyTransform($file)) { | ||||
| try { | |||||
| $xformed_file = $xforms[$transform]->applyTransform($file); | $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); | |||||
| } | } | ||||
| } | } | ||||
| if (!$xformed_file) { | if (!$xformed_file) { | ||||
| switch ($transform) { | switch ($transform) { | ||||
| case 'thumb-profile': | case 'thumb-profile': | ||||
| $xformed_file = $this->executeThumbTransform($file, 50, 50); | $xformed_file = $this->executeThumbTransform($file, 50, 50); | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||