Conpherence - add crop
Summary: mainly, this adds the image cropper - yay! - also removes the file image from the handle stuff I added in V1. now we do all this crazy photo stuff. Test Plan: - uploaded a photo by dragging to header and noted 120 x 80 showed up on reload - uploaded a photo by dragging to edit dialogue spot and noted 120 x 80 showed up on reload - cropped a photo - noted it cropped right - cropped a photo again and again and again - seems like it crops okay Reviewers: epriestley, chad Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T2418, T2399 Differential Revision: https://secure.phabricator.com/D4790
This commit is contained in:
@@ -9,6 +9,18 @@ final class ConpherenceThreadQuery
|
||||
private $phids;
|
||||
private $ids;
|
||||
private $needWidgetData;
|
||||
private $needHeaderPics;
|
||||
private $needOrigPics;
|
||||
|
||||
public function needOrigPics($need_orig_pics) {
|
||||
$this->needOrigPics = $need_orig_pics;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needHeaderPics($need_header_pics) {
|
||||
$this->needHeaderPics = $need_header_pics;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function needWidgetData($need_widget_data) {
|
||||
$this->needWidgetData = $need_widget_data;
|
||||
@@ -47,6 +59,12 @@ final class ConpherenceThreadQuery
|
||||
if ($this->needWidgetData) {
|
||||
$this->loadWidgetData($conpherences);
|
||||
}
|
||||
if ($this->needOrigPics) {
|
||||
$this->loadOrigPics($conpherences);
|
||||
}
|
||||
if ($this->needHeaderPics) {
|
||||
$this->loadHeaderPics($conpherences);
|
||||
}
|
||||
}
|
||||
|
||||
return $conpherences;
|
||||
@@ -187,4 +205,39 @@ final class ConpherenceThreadQuery
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function loadOrigPics(array $conpherences) {
|
||||
return $this->loadPics(
|
||||
$conpherences,
|
||||
ConpherenceImageData::SIZE_ORIG
|
||||
);
|
||||
}
|
||||
|
||||
private function loadHeaderPics(array $conpherences) {
|
||||
return $this->loadPics(
|
||||
$conpherences,
|
||||
ConpherenceImageData::SIZE_HEAD
|
||||
);
|
||||
}
|
||||
|
||||
private function loadPics(array $conpherences, $size) {
|
||||
$conpherence_pic_phids = array();
|
||||
foreach ($conpherences as $conpherence) {
|
||||
$phid = $conpherence->getImagePHID($size);
|
||||
if ($phid) {
|
||||
$conpherence_pic_phids[$conpherence->getPHID()] = $phid;
|
||||
}
|
||||
}
|
||||
$files = id(new PhabricatorFileQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withPHIDs($conpherence_pic_phids)
|
||||
->execute();
|
||||
$files = mpull($files, null, 'getPHID');
|
||||
|
||||
foreach ($conpherence_pic_phids as $conpherence_phid => $pic_phid) {
|
||||
$conpherences[$conpherence_phid]->setImage($files[$pic_phid], $size);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user