Trying to using Intervention Image to resize images. Got that part working. Now I want to cache the images for 10 minutes, but I am getting this stack trace:
ErrorException in ArticlesController.php line 150: Missing argument 2 for App\Http\Controllers\ArticlesController::App\Http\Controllers{closure}(), called in /home/vagrant/Sites/vision/vendor/intervention/image/src/Intervention/Image/ImageManager.php on line 85 and defined
This is where the magic is happening, in ArticlesController.php:
private function createArticle(ArticleRequest $request)
{
$article = Auth::user()->articles()->create($request->all());
$this->syncTags($article, $request->input('tag_list'));
$image = $request->file('image');
$directory = 'img/articles/';
$path = $image->getClientOriginalName();
$image->move($directory, $path);
Image::create([
'path' => $path,
'article_id' => $article->id
]);
// This one resizes the image successfully.
ImgResizer::make($directory . $path)->fit(600, 360)->save($directory . $path);
// This one is supposed to resize and cache the image, but spits the error above.
ImgResizer::cache(function($image, $directory, $path) {
$image->make($directory . $path)->fit(600, 360)->save($directory . $path);
}, 10);
}
Don't worry, I'm not using both statements at once. Just showing what I am doing in both and hopefully someone can lead me in the right direction and show me what I'm doing wrong, because I don't see it.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire