本文整理汇总了PHP中SiteHelpers::resize_crop_image方法的典型用法代码示例。如果您正苦于以下问题:PHP SiteHelpers::resize_crop_image方法的具体用法?PHP SiteHelpers::resize_crop_image怎么用?PHP SiteHelpers::resize_crop_image使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiteHelpers
的用法示例。
在下文中一共展示了SiteHelpers::resize_crop_image方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postSave
function postSave(Request $request)
{
$validator = Validator::make($request->all(), News::$rules);
if ($validator->passes()) {
$data = $this->getDataPost('news');
$type_pro = !isset($data['news_id']) ? "add" : "edit";
//Make alias
//$data['alias'] = \SiteHelpers::seoUrl( trim($data['name']));
$data = \SiteHelpers::processTimeUpdate($type_pro, $data);
if (!is_null(\Input::file('file'))) {
$file = \Input::file('file');
//Edit Path
$destinationPath = './uploads/news/';
$filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
//if you need extension of the file
//Edit file name
$newfilename = 'news_' . time() . '.' . $extension;
$uploadSuccess = \Input::file('file')->move($destinationPath, $newfilename);
if ($uploadSuccess) {
//Edit name of field image
$data['news_picture'] = $newfilename;
$orgFile = $destinationPath . '/' . $newfilename;
$thumbFile = $destinationPath . '/thumb/' . $newfilename;
//SiteHelpers::resizewidth("213",$orgFile,$thumbFile);
//Edit size thumb image
\SiteHelpers::resize_crop_image('600', '450', $orgFile, $thumbFile);
if ($type_pro == "edit") {
$data_old = $this->model->getRow(\Input::get('news_id'));
//Edit folder name and field name
@unlink(ROOT . '/uploads/news/' . $data_old->aboutus_image);
@unlink(ROOT . '/uploads/news/thumb/' . $data_old->aboutus_image);
}
}
}
$id = $this->model->insertRow($data, \Input::get('news_id'));
if (!is_null($request->input('apply'))) {
$return = 'news/update/' . $id . '?return=' . self::returnUrl();
} else {
$return = 'news?return=' . self::returnUrl();
}
// Insert logs into database
if ($request->input('news_id') == '') {
\SiteHelpers::auditTrail($request, 'New Data with ID ' . $id . ' Has been Inserted !');
} else {
\SiteHelpers::auditTrail($request, 'Data with ID ' . $id . ' Has been Updated !');
}
return Redirect::to($return)->with('messagetext', \Lang::get('core.note_success'))->with('msgstatus', 'success');
} else {
$id = \Input::get('news_id') ? \Input::get('news_id') : "";
return Redirect::to('news/update/' . $id)->with('messagetext', \Lang::get('core.note_error'))->with('msgstatus', 'error')->withErrors($validator)->withInput();
}
}
示例2: postSave
function postSave($id = 0)
{
//$trackUri = $this->data['trackUri'];
$rules = Advertise::$rules;
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
$data = $this->getDataPost('advertise');
$data['created'] = time();
if (!is_null(Input::file('file'))) {
$file = Input::file('file');
$destinationPath = './uploads/advertise/';
$filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
//if you need extension of the file
$newfilename = SiteHelpers::seoUrl(Input::get('advertise_name')) . '_' . time() . '.' . $extension;
$uploadSuccess = Input::file('file')->move($destinationPath, $newfilename);
if ($uploadSuccess) {
$data['image'] = $newfilename;
$orgFile = $destinationPath . '/' . $newfilename;
$thumbFile = $destinationPath . '/thumb/' . $newfilename;
if (Input::get('position') == 1) {
SiteHelpers::resizewidth("213", $orgFile, $thumbFile);
//SiteHelpers::resize_crop_image('235' , '235' , $orgFile , $thumbFile);
} else {
//SiteHelpers::resizewidth("235",$orgFile,$thumbFile);
SiteHelpers::resize_crop_image('892', '111', $orgFile, $thumbFile);
}
if (Input::get('advertise_id')) {
$data_old = $this->model->getRow(Input::get('advertise_id'));
@unlink(ROOT . '/uploads/advertise/' . $data_old->image);
@unlink(ROOT . '/uploads/advertise/thumb/' . $data_old->image);
}
}
}
$ID = $this->model->insertRow($data, Input::get('advertise_id'));
// Input logs
if (Input::get('advertise_id') == '') {
$this->inputLogs("New Entry row with ID : {$ID} , Has Been Save Successfull");
$id = SiteHelpers::encryptID($ID);
} else {
$this->inputLogs(" ID : {$ID} , Has Been Changed Successfull");
}
// Redirect after save
$md = str_replace(" ", "+", Input::get('md'));
$redirect = !is_null(Input::get('apply')) ? 'advertise/add/' . $id . '?md=' : 'advertise?md=';
return Redirect::to($redirect)->with('message', SiteHelpers::alert('success', Lang::get('core.note_success')));
} else {
return Redirect::to('advertise/add/' . $id . '?md=')->with('message', SiteHelpers::alert('error', Lang::get('core.note_error')))->withErrors($validator)->withInput();
}
}
示例3: postSuatin
public function postSuatin()
{
if (!Session::has('customer') || Input::get('post_id') == '') {
return Redirect::to('');
}
$rules = array('post_name' => 'required', 'post_code' => 'required|max:10', 'post_category' => 'required|Numeric', 'post_link' => 'required', 'post_price' => 'required|Numeric', 'post_price_promotion' => 'Numeric', 'phone' => 'required', 'post_image' => 'mimes:gif,png,jpg,jpeg|max:20000');
if (CNF_RECAPTCHA == 'true') {
$rules['recaptcha_response_field'] = 'required|recaptcha';
}
$validator = Validator::make(Input::all(), $rules);
if ($validator->passes()) {
$ses_cus = Session::get('customer');
$customer = DB::table('customer')->where('customer_id', '=', $ses_cus['id'])->first();
$data = $this->getDataPost('post');
$data['created'] = time();
$data['customer_id'] = $ses_cus['id'];
$data['post_slug'] = SiteHelpers::seoUrl(trim($data['post_name']));
$data['active'] = 1;
$data['status'] = 1;
unset($data['lang']);
$mdPost = new Post();
if (!is_null(Input::file('post_image'))) {
$file = Input::file('post_image');
$destinationPath = './uploads/post/';
$filename = $file->getClientOriginalName();
$extension = $file->getClientOriginalExtension();
//if you need extension of the file
$newfilename = SiteHelpers::seoUrl(trim($data['post_name'])) . '_' . time() . '.' . $extension;
$uploadSuccess = Input::file('post_image')->move($destinationPath, $newfilename);
if ($uploadSuccess) {
$data['post_image'] = $newfilename;
$orgFile = $destinationPath . '/' . $newfilename;
$thumbFile = $destinationPath . '/thumb/' . $newfilename;
SiteHelpers::resize_crop_image('169', '166', $orgFile, $thumbFile);
$data_old = $mdPost->getRow(Input::get('post_id'));
@unlink(ROOT . '/uploads/advertise/' . $data_old->post_image);
@unlink(ROOT . '/uploads/advertise/thumb/' . $data_old->post_image);
}
} else {
unset($data['post_image']);
}
$ID = $mdPost->insertRow($data, $data['post_id']);
return Redirect::to('thong-bao.html')->with('message', SiteHelpers::alert('success', 'Thao tác thành công ! Bài đăng của bạn đang chờ duyệt !'));
} else {
$input_rd = Input::all();
unset($input_rd['post_image']);
return Redirect::back()->with('message_dangtin', SiteHelpers::alert('error', 'Vui lòng xác nhận các thông tin bên dưới'))->with('input', $input_rd)->withErrors($validator)->withInput();
}
}