Ejemplo n.º 1
0
 public function image()
 {
     if ($this->value) {
         $this->column_html .= '<a href="' . Config::get('app.url') . $this->value . '" data-toggle="lightbox-image"><img src="' . Image::url(Config::get('app.url') . $this->value, null, 40) . '"></a>' . PHP_EOL;
     }
     $this->column_html .= '</td>' . PHP_EOL;
     return $this->column_html;
 }
 public function upload(Request $request)
 {
     if ($request->hasFile('file')) {
         $file = $request->file('file');
         $tmpPath = storage_path('cache/tmp');
         $imagesPath = storage_path('cache/images');
         @mkdir($tmpPath, 0775, true);
         @mkdir($imagesPath, 0775, true);
         $fileInfo = pathinfo($file->getClientOriginalName());
         $fileName = str_slug(str_limit($fileInfo['filename'], 50, '') . '-' . rand(1, 999)) . '.' . $file->getClientOriginalExtension();
         $file->move($tmpPath, $fileName);
         FolkloreImage::make(storage_path('cache/tmp') . '/' . $fileName, ['width' => config('mgalleries.galleries.width', 640), 'height' => config('mgalleries.galleries.height', 480), 'quality' => config('mgalleries.galleries.quality', 90)])->save($imagesPath . '/' . $fileName);
         return ['status' => 'success', 'name' => $fileName];
     }
     return ['status' => 'error'];
 }
Ejemplo n.º 3
0
 /**
  * Store a newly created resource in storage.
  *
  * @param CreateAlbumRequest $request
  * @return Response
  */
 public function store(CreateAlbumRequest $request, Album $album)
 {
     $uploaded_file = $request->file('image_file');
     $parameter = $request->all();
     unset($parameter['image_file']);
     $album = $album->create($parameter);
     if (isset($uploaded_file)) {
         $ext = $uploaded_file->getClientOriginalExtension();
         $imageName = $album->id . "." . $ext;
         $uploaded_file->move(base_path() . '/public/img/uploads/album/', $imageName);
         Image::make(base_path() . '/public/img/uploads/album/' . $imageName, array('width' => 160, 'height' => 200))->save(base_path() . '/public/img/uploads/thumbnails/album/' . $imageName);
         $album->update(array('image' => $imageName));
     }
     Session::flash('message', 'The Album was successfully added!.');
     Session::flash('flash_type', 'alert-success');
     return redirect('albums');
 }
Ejemplo n.º 4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Event $event, CreateEventRequest $request)
 {
     $ext1 = $request->file('image_home')->getClientOriginalExtension();
     $ext2 = $request->file('image_away')->getClientOriginalExtension();
     $event = $event->create($request->all());
     $imageName1 = $event->id . "." . $ext1;
     $imageName2 = $event->id . "." . $ext2;
     $request->file('image_home')->move(base_path() . '/public/img/uploads/home/', $imageName1);
     Image::make(base_path() . '/public/img/uploads/home/' . $imageName1, array('width' => 125, 'height' => 100))->save(base_path() . '/public/img/uploads/home/' . $imageName1);
     $request->file('image_away')->move(base_path() . '/public/img/uploads/away/', $imageName2);
     Image::make(base_path() . '/public/img/uploads/away/' . $imageName2, array('width' => 125, 'height' => 100))->save(base_path() . '/public/img/uploads/away/' . $imageName2);
     $event->update(array('image_home' => $imageName1));
     $event->update(array('image_away' => $imageName2));
     Session::flash('message', 'The event was successfully added!.');
     Session::flash('flash_type', 'alert-success');
     return redirect('events');
 }
 public function storePicture($file, $type, $name)
 {
     $userid = Auth::user()->id;
     $extension = $file->getClientOriginalExtension();
     $filename = $name . '.' . $extension;
     $url = 'img/' . $type;
     $exists = File::exists(public_path() . '/' . $url . '/' . $filename);
     if ($exists) {
         //Ajout d'une composante random pour ne pas écraser le fichier
         $rdm = str_random(6);
         $file->move($url, $name . $rdm . '.' . $extension);
         $url = $url . '/' . $name . $rdm . '.' . $extension;
         $thumb_url = 'img/thumb/thumb-' . $type . '-' . $name . $rdm . '.' . $extension;
     } else {
         $file->move($url, $filename);
         $url = $url . '/' . $filename;
         $thumb_url = 'img/thumb/thumb-' . $type . '-' . $filename;
     }
     $thumbnail = Image::open($url);
     $new_item = User::find($userid)->pictures()->create(['nom' => $filename, 'url' => $url, 'actif' => false, 'type' => $type, 'thumb_url' => $thumb_url])->save();
     Image::make($url, array('width' => 300, 'height' => 300))->save($thumb_url);
 }
Ejemplo n.º 6
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, Slider $slider, CreateSliderRequest $request)
 {
     $slider_to_update = $slider->find($id);
     $uploaded_image = $request->file('image_upload');
     if (isset($uploaded_image)) {
         $ext = $uploaded_image->getClientOriginalExtension();
         $newImageName = $slider_to_update->id . "." . $ext;
         Image::make(base_path() . '/public/img/uploads/slider/' . $newImageName, array('width' => 774, 'height' => 329))->save(base_path() . '/public/img/uploads/slider/' . $newImageName);
         $parameter = $request->all();
         $parameter['image'] = $newImageName;
         /* remove this field from the parameters list */
         unset($parameter['image_upload']);
         $slider_to_update->update($parameter);
     } else {
         $slider_to_update->update($request->all());
     }
     Session::flash('message', 'The content was successfully updated!.');
     Session::flash('flash_type', 'alert-success');
     return redirect('sliders');
 }
Ejemplo n.º 7
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id, CreateCoachRequest $request, Coach $coach)
 {
     $player_to_update = $coach->find($id);
     $uploaded_image = $request->file('image_upload');
     $parameter = $request->all();
     if (isset($uploaded_image)) {
         $ext = $uploaded_image->getClientOriginalExtension();
         $newImageName = $player_to_update->id . "." . $ext;
         $uploaded_image->move(base_path() . '/public/img/uploads/coach/', $newImageName);
         Image::make(base_path() . '/public/img/uploads/coach/' . $newImageName, array('width' => 774, 'height' => 329))->save(base_path() . '/public/img/uploads/coach/' . $newImageName);
         $parameter = $request->all();
         $parameter['image'] = $newImageName;
         /* remove this field from the parameters list */
         unset($parameter['image_upload']);
         $player_to_update->update($parameter);
     } else {
         $player_to_update->update($request->all());
         $player_to_update->update($parameter);
     }
     return redirect('coach');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int $id
  * @return Response
  */
 public function update($id, CreateArticleRequest $request, Article $article)
 {
     $article_to_update = $article->find($id);
     $uploaded_image = $request->file('image_file');
     $parameter = $request->all();
     if (isset($uploaded_image)) {
         $ext = $uploaded_image->getClientOriginalExtension();
         $newImageName = $article_to_update->id . "." . $ext;
         $uploaded_image->move(base_path() . '/public/img/uploads/article/', $newImageName);
         Image::make(base_path() . '/public/img/uploads/article/' . $newImageName, array('width' => 170, 'height' => 120))->save(base_path() . '/public/img/uploads/article/' . $newImageName);
         unset($parameter['image_file']);
         $parameter['image'] = $newImageName;
         $article_to_update->update($parameter);
     } else {
         $parameter['image'] = $article_to_update->image;
         $article_to_update->update($parameter);
     }
     Session::flash('message', 'The article was successfully edited!.');
     Session::flash('flash_type', 'alert-success');
     return redirect('articles');
 }
Ejemplo n.º 9
0
 /**
  * Update the specified resource in storage.
  *
  * @param Requests\UpdatePostFormRequest $request
  * @param  int $id
  * @return Response
  */
 public function update(Requests\UpdatePostFormRequest $request, $id)
 {
     $params = $request->all();
     $params['user_id'] = Auth::user()->id;
     $post = Post::find($id);
     $post->tags()->detach();
     $post->update($params);
     $post->tags()->attach($request->input('tags'));
     if ($request->hasFile('thumbnail_link')) {
         $file = $request->file('thumbnail_link');
         $ext = $file->getClientOriginalExtension();
         $rand_name = $params['user_id'] . '.' . $ext;
         Image::make($file->getRealPath(), ['width' => 200, 'height' => 200])->save('assets/upload/thumb-' . $rand_name);
         $post->thumbnail_link = 'thumb-' . $rand_name;
     }
     $post->save();
     return redirect('dashboard/conference')->with('message', 'Conférence modifiée');
 }
Ejemplo n.º 10
0
 }
 $targetFile = $targetPath . $_FILES['file']['name'];
 $targetFileThumb = $targetPathThumb . $_FILES['file']['name'];
 // check if image (and supported)
 if (in_array(fix_strtolower($info['extension']), $ext_img)) {
     $is_img = TRUE;
 } else {
     $is_img = FALSE;
 }
 // upload
 move_uploaded_file($tempFile, $targetFile);
 chmod($targetFile, 0755);
 if ($is_img) {
     Image::make($targetFile, ['width' => 200])->save($storeFolderThumb . '200/' . $_FILES['file']['name']);
     Image::make($targetFile, ['width' => 330])->save($storeFolderThumb . '330/' . $_FILES['file']['name']);
     Image::make($targetFile, ['width' => 122, 'height' => 91, 'crop' => true])->save($storeFolderThumb . $_FILES['file']['name']);
     $memory_error = FALSE;
     /*if ( ! create_img($targetFile, $targetFileThumb, 122, 91))
     			{
     				$memory_error = FALSE;
     			}
     			else
     			{
     				// TODO something with this long function baaaah...
     				if( ! new_thumbnails_creation($targetPath,$targetFile,$_FILES['file']['name'],$current_path,$relative_image_creation,$relative_path_from_current_pos,$relative_image_creation_name_to_prepend,$relative_image_creation_name_to_append,$relative_image_creation_width,$relative_image_creation_height,$relative_image_creation_option,$fixed_image_creation,$fixed_path_from_filemanager,$fixed_image_creation_name_to_prepend,$fixed_image_creation_to_append,$fixed_image_creation_width,$fixed_image_creation_height,$fixed_image_creation_option))
     				{
     					$memory_error = FALSE;
     				}
     				else
     				{
     					$imginfo = getimagesize($targetFile);