function ajax_avatar() { if (Auth::guest()) { exit; } $userId = Auth::user()->id; $options = array('upload_dir' => app('path.base') . '/uploads/', 'upload_url' => App::url('uploads/'), 'max_file_size' => 5000000, 'max_width' => 2000, 'max_height' => 2000, 'versions' => array('' => array('crop' => true, 'max_width' => 300, 'max_height' => 300)), 'upload_start' => function ($image, $instance) use($userId) { $image->name = "~{$userId}.{$image->type}"; }, 'crop_start' => function ($image, $instance) use($userId) { $image->name = "{$userId}.{$image->type}"; }, 'crop_complete' => function ($image, $instance) use($userId) { Usermeta::update($userId, 'avatar_image', $image->name); }); new Hazzard\Support\ImagePicker($options, trans('imgpicker')); }