Skip to content

Powerimage is a dynamic image handler for laravel

License

Notifications You must be signed in to change notification settings

alcodo/powerimage

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Powerimage

Build Status Total Downloads Latest Stable Version License

Powerimage is a dynamic image handler for laravel. It uses the package thephpleague/glide for convert and spatie/image-optimizer for optimize the image.

After the installation you can request any image that you have uploaded in laravel. Example:
example.com/images/cat.jpg (Original)
example.com/images/cat_w=200&h=200.jpg (Convert)

The workflow is very simple. If image isn't found, laravel throw a exception. This package creates only one time this image. And on the next request the image will return form your webserver like nginx (fast response).

Structure:

{domain}/{path}/{fileimage name}_{resize parameter}.{extension}

Delimiter: _

Installation

Add packages:

    composer require alcodo/powerimage:dev-master

Add powerimage handler in app/Exceptions/Handler.php:

    public function render($request, Exception $exception)
    {
        PowerImage::check($request, $exception);

        return parent::render($request, $exception);
    }

And by the way you can inlcude or exclude paths that you want use powerimage example:

    public function render($request, Exception $exception)
    {
        if (PowerImage::include ($request, ['/images/*', '/gallery/*'])) {
            PowerImage::check($request, $exception);
        }

        // or

        if (PowerImage::exclude($request, ['/user/*'])) {
            PowerImage::check($request, $exception);
        }

        return parent::render($request, $exception);
    }

Helper

Create powerimage path helper:

    powerimage('images/video.png', ['w' => 200, 'h' => 350]);
    
    // outut
    'images/video_w=200&h=350.png'
    
    // or direct in blade template
    <img class="img-fluid" src="{{ powerimage(Storage::url($image->filepath), ['w'=> 260, 'h' => 260])  }}" alt=""/>

License

The MIT License (MIT). Please see LICENSE for more information.

About

Powerimage is a dynamic image handler for laravel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages