I have fairly simple site in Laravel 5 with few static pages. One of features site uses is Glide server for image manipulation so in my composer.json
I have this line
"league/glide": "0.3.*",
Apparently as a dependancy this package is also installed
"intervention/image": "~2.1",
Now it seems like I've set everything up, but when I try hitting some image via url, I get
NotReadableException in Decoder.php line 21:
Unable to read image from file (/tmp/GlidesCmrgC).
Where everything after Glide
in tmp
file name is random. So obviously file is loaded and not missing, but still something is going wrong. I was looking into documentation, but couldn't find anything.
Here is an ImageController file that is routed to handle Glide requests
<?php
namespace app\Http\Controllers;
use Illuminate\Http\Request;
use League\Glide\Server as GlideServer;
class ImageController extends Controller
{
public function output(Request $request, GlideServer $glide)
{
// Also tried this
// $glide->outputImage($request);
$glide->getImageResponse($request);
}
}
In my AppServiceProvider.php
I have this part
$this->app->singleton('League\Glide\Server', function ($app) {
$filesystem = $app->make('Illuminate\Contracts\Filesystem\Filesystem');
return \League\Glide\ServerFactory::create([
'source' => $filesystem->getDriver(),
'cache' => $filesystem->getDriver()
]);
// Also tried this
// $filesystem = $app->make('League\Flysystem\FilesystemInterface');
/* return \League\Glide\ServerFactory::create([
'source' => $filesystem,
'cache' => storage_path().'/app/.cache',
'base_url' => 'img',
]); */
});
And in routes.php
I have this route
get('/img/{path}', 'ImageController@output');
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire