我的用户上传存储在storage/profile_picture/user1.png中的个人资料图片。我使用Filesystem和Storage类来做到这一点。Laravel图片默认
要检索图像我用{!! Html::image(route('profile.thumbnail', $user->profilepic_filename), "Your Picture Here", ['class'=>'img-responsive']) !!}
在我的控制器我有
public function thumbnail($filename)
{
$user = User::where('profilepicture_filename', '=', $filename)->firstOrFail();
$file = Storage::disk('local_profile')->get($user->profilepicture_filename);
//$file = URL::asset('/images/default_profilepicture.png'); //doesn't work
return (new Response($file, 200))->header('Content-Type', $mime);
}
}
我想获得一个默认的形象,如果没有找到资料图片或没有上传。我该怎么做?
感谢,
ķ