Modularize file transforms and provide a "transforms" UI
Summary:
Ref T7707. Available transforms are currently relatively hard-coded and don't really have any support UI.
Modularize them so we can build some support UI.
This doesn't actually //use// any of the new stuff yet: I want to make a clean cutover once I fix the aspect ratio stuff so I can pick up a cachekey/URI change as a side effect.
Test Plan: {F400524}
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: chad, epriestley
Maniphest Tasks: T7707
Differential Revision: https://secure.phabricator.com/D12808
This commit is contained in:
@@ -48,21 +48,33 @@ final class PhabricatorFileTransformController
|
||||
// protection.
|
||||
$unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
|
||||
|
||||
switch ($transform) {
|
||||
case 'thumb-profile':
|
||||
$xformed_file = $this->executeThumbTransform($file, 50, 50);
|
||||
break;
|
||||
case 'thumb-280x210':
|
||||
$xformed_file = $this->executeThumbTransform($file, 280, 210);
|
||||
break;
|
||||
case 'preview-100':
|
||||
$xformed_file = $this->executePreviewTransform($file, 100);
|
||||
break;
|
||||
case 'preview-220':
|
||||
$xformed_file = $this->executePreviewTransform($file, 220);
|
||||
break;
|
||||
default:
|
||||
return new Aphront400Response();
|
||||
$xformed_file = null;
|
||||
|
||||
$xforms = PhabricatorFileTransform::getAllTransforms();
|
||||
if (isset($xforms[$transform])) {
|
||||
$xform = $xforms[$transform];
|
||||
if ($xform->canApplyTransform($file)) {
|
||||
$xformed_file = $xforms[$transform]->applyTransform($file);
|
||||
}
|
||||
}
|
||||
|
||||
if (!$xformed_file) {
|
||||
switch ($transform) {
|
||||
case 'thumb-profile':
|
||||
$xformed_file = $this->executeThumbTransform($file, 50, 50);
|
||||
break;
|
||||
case 'thumb-280x210':
|
||||
$xformed_file = $this->executeThumbTransform($file, 280, 210);
|
||||
break;
|
||||
case 'preview-100':
|
||||
$xformed_file = $this->executePreviewTransform($file, 100);
|
||||
break;
|
||||
case 'preview-220':
|
||||
$xformed_file = $this->executePreviewTransform($file, 220);
|
||||
break;
|
||||
default:
|
||||
return new Aphront400Response();
|
||||
}
|
||||
}
|
||||
|
||||
if (!$xformed_file) {
|
||||
|
||||
Reference in New Issue
Block a user