public function crop() { // auth Auth::isAdminAuthorized($this->signedUser, 'admin.media.crop', true, '/media'); // action $id = Converter::int('id'); $x = Converter::int('x', 'post'); $y = Converter::int('y', 'post'); $w = Converter::int('w', 'post'); $h = Converter::int('h', 'post'); $media = \Rebond\Core\Media\Data::loadById($id); if (!isset($media)) { Session::adminError('itemNotFound', [$id], '/media'); } // action if (isset($_POST['save'])) { $file = \Rebond\Util\Media::showFromModel($media, 920, 900, \Rebond\Core\RatioType::KEEP_MIN); $filename = \Rebond\Util\File::getFilename($file); $upload = \Rebond\Util\Media::crop(\Rebond\Config::getPath('media'), $media->getPath(), $filename, $x, $y, $w, $h); // add Media // copy media by setting MediaId to 0 $fullPathFile = \Rebond\Config::getPath('media') . $media->getPath() . $upload; $media->setId(0); $media->setOriginalFilename($upload); $media->setWidth($_POST['w']); $media->setHeight($_POST['h']); $media->setFilesize(filesize($fullPathFile)); $media->setUpload($upload); $media->setCreatedDate('now'); $media->save(); Session::adminSuccess('saved', '/media'); } // view $this->setTpl(); // media $tplMain = new Template(Template::SITE, ['admin', 'media']); $tplMain->set('model', $media); // layout $this->tplLayout->add('column1', $tplMain->render('crop')); //master $this->tplMaster->set('layout', $this->tplLayout->render('layout-1-col')); $this->tplMaster->set('jsLauncher', 'mediaCrop'); return $this->tplMaster->render('tpl-default'); }