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:
epriestley
2015-05-12 06:16:18 -07:00
parent ae32d1afb8
commit c998e44b5a
9 changed files with 319 additions and 16 deletions

View File

@@ -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) {