ireisaac / laraimage

轻松使用laravel中的glide图像包

0.1.1 2016-02-03 18:20 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:20:42 UTC


README

我是一个php leagues Glide Image包的粉丝,并在我的大多数项目中使用它。这个包希望能节省别人的时间。如果你在将Glide集成到laravel方面有不同的处理方式,请告诉我。

安装

通过Composer

composer require ireisaac/laraimage
php artisan vendor:publish

在config/app.php中注册服务提供者,在长提供者数组的末尾检查大约在第155-160行

    'providers' => [
        ...
        IreIsaac\LaraImage\ImageServiceProvider::class,
    ]

如果你想访问一个非常有用的外观,请在config/app.php中注册它

    'Image' => \IreIsaac\LaraImage\ImageFacade::class,

如果你想使用artisan命令清除应用程序生成的缓存图像,请使用包含的命令。在文件app/Console/Kernel.php中添加

    protected $commands = [
        ...
        IreIsaac\LaraImage\Commands\ClearImageCache::class,
    ];

当请求的图像不存在时渲染默认图像,将名为"ImageNotFound"的图像放在storage/app/images/default/中,现在你可以在App\Exceptions\Handler@render中添加以下片段,就这样。

    if($e instanceof \League\Glide\Filesystem\FileNotFoundException) {

        return Image::outputImage(config('images.placeholder'), $request->all());
    }

用法