1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-24 21:48:21 +01:00
phorge-phorge/src/applications/conpherence/view/ConpherencePicCropControl.php
Bob Trahan 16ce63ec20 Conpherence - add back in custom images
Summary: Fixes T7254. This reverts the previous functionality, but makes pertinent updates like scaling the images to 35 x 35. Codebase had moved on quite a bit so far from a straight revert but nothing too tricky relative to the code that was here before. This does not allow for changing the images from the conpherence durable column view -- that would require some JS trickery, but also doesn't fit into the current notion of the column being "light". Can always modify this later.

Test Plan:
 - from full conpherence, uploaded a square pic and things looked nice
 - from full conpherence, uploaded a rectangular pic and wasnt happy, so reinvoked edit dialog and used crop control to make it better
 - noted could not update picture from conpherence durable column
 - used different user and noted could see custom picture

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: CodeMouse92, Korvin, epriestley

Maniphest Tasks: T7254

Differential Revision: https://secure.phabricator.com/D12648
2015-05-04 13:52:22 -07:00

78 lines
1.7 KiB
PHP

<?php
final class ConpherencePicCropControl extends AphrontFormControl {
protected function getCustomControlClass() {
return 'aphront-form-crop';
}
protected function renderInput() {
$width = ConpherenceImageData::CROP_WIDTH;
$height = ConpherenceImageData::CROP_HEIGHT;
$file = $this->getValue();
if ($file === null) {
return phutil_tag(
'img',
array(
'src' => PhabricatorUser::getDefaultProfileImageURI(),
),
'');
}
$c_id = celerity_generate_unique_node_id();
$metadata = $file->getMetadata();
$scale = PhabricatorImageTransformer::getScaleForCrop(
$file,
$width,
$height);
Javelin::initBehavior(
'aphront-crop',
array(
'cropBoxID' => $c_id,
'width' => $width,
'height' => $height,
'scale' => $scale,
'imageH' => $metadata[PhabricatorFile::METADATA_IMAGE_HEIGHT],
'imageW' => $metadata[PhabricatorFile::METADATA_IMAGE_WIDTH],
));
return javelin_tag(
'div',
array(
'id' => $c_id,
'sigil' => 'crop-box',
'mustcapture' => true,
'class' => 'crop-box',
),
array(
javelin_tag(
'img',
array(
'src' => $file->getBestURI(),
'class' => 'crop-image',
'sigil' => 'crop-image',
),
''),
javelin_tag(
'input',
array(
'type' => 'hidden',
'name' => 'image_x',
'sigil' => 'crop-x',
),
''),
javelin_tag(
'input',
array(
'type' => 'hidden',
'name' => 'image_y',
'sigil' => 'crop-y',
),
''),
));
}
}