getAuthIdentifier() !== (int)$post->user_id) { throw new UnauthorizedHttpException('Cette image ne vous appartient pas.'); } $path = sprintf('%s/%s/%s', storage_path('app'), Auth::user()->getFolder(), $image); if (!is_readable($path)) { throw new NotFoundHttpException(); } $img = Image::make($path); if ('o:full' !== $options) { $options = explode('!', $options); $width = null; $height = null; foreach ($options as $option) { $current_option = explode(':', $option); foreach ($current_option as $current_option_name => $current_option_value) { switch ($current_option_name) { case 'w': $width = $current_option_value; break; case 'h': $height = $current_option_value; break; } } } //http://image.intervention.io/getting_started/ $img->resize($width, $height, static function (Constraint $constraint) { $constraint->aspectRatio(); }); } return $img->response(File::extension($path)); } /** * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View */ public function gallery() { $posts_with_image = Post::where('user_id', Auth::user()->getAuthIdentifier()) ->where('image', '!=', 'null') ->orderBy('created_at', 'desc') ->paginate(30); return view('gallery.my', [ 'posts' => $posts_with_image, ]); } }