2017 © Pedro Peláez
 

library laravel-clyde

Image uploads and manipulation for Laravel, a wrapper around Glide

image

antennaio/laravel-clyde

Image uploads and manipulation for Laravel, a wrapper around Glide

  • Thursday, August 25, 2016
  • by antennaio
  • Repository
  • 5 Watchers
  • 27 Stars
  • 1,447 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 11 Versions
  • 3 % Grown

The README.md

Laravel Clyde

Image uploads and manipulation for Laravel, a wrapper around Glide, (*1)

You can use the package to upload your images to local filesystem or S3 and display them on your site in various sizes. Thanks to Glide all manipulated images will be cached and reserved on subsequent visits., (*2)

Clyde The Glide, (*3)

Installation

Install through composer:, (*4)

composer require antennaio/laravel-clyde:~0.0.1

Add the service provider to config:, (*5)

// config/app.php
'provider' => [
    ...
    Antennaio\Clyde\ClydeServiceProvider::class,
    ...
];

If you intend to use facades, install those as well:, (*6)

// config/app.php
'aliases' => [
    ...
    'ClydeUpload' => Antennaio\Clyde\Facades\ClydeUpload::class,
    'ClydeImage' => Antennaio\Clyde\Facades\ClydeImage::class,
    ...
];

Publish configuration:, (*7)

php artisan vendor:publish --provider="Antennaio\Clyde\ClydeServiceProvider"

Uploads

You can use dependency injection or facades, it's up to you., (*8)

use Antennaio\Clyde\ClydeUpload;

...

protected $uploads;

public function __construct(ClydeUpload $uploads)
{
    $this->uploads = $uploads;
}

public function upload(Request $request)
{
    if ($request->hasFile('image')) {
        $filename = $this->uploads->upload($request->file('image'));
    }
}
use Antennaio\Clyde\Facades\ClydeUpload;

...

public function upload(Request $request)
{
    if ($request->hasFile('image')) {
        $filename = ClydeUpload::upload($request->file('image'));
    }
}

Each filename generated by Clyde is unique. Make sure to store the filename, so that you can display the image at a later time., (*9)

You can control the location of where the uploaded file will be saved by passing an additional argument to the upload method. Below is an example of how to save an image and keep its original name:, (*10)

ClydeUpload::upload($request->file('image'), $request->file('image')->getClientOriginalName());

You may also use a closure to modify the file path:, (*11)

ClydeUpload::upload($request->file('image'), function ($filename) {
    return 'profile-images'.DIRECTORY_SEPARATOR.$filename;
});

You can also check if an image already exists:, (*12)

// returns true or false
ClydeUpload::exists('image.jpg');

Or delete a previously uploaded image:, (*13)

ClydeUpload::delete('image.jpg');

Displaying images

<img src="{{ ClydeImage::url('56a1472beca5d.jpg') }}">

You can pass various image manipulations as the second parameter:, (*14)

<img src="{{ ClydeImage::url('56a1472beca5d.jpg', ['w' => 800, 'h' => 600, 'fit' => 'crop']) }}">

For the full list of available manipulations take a look at the Glide docs:, (*15)

http://glide.thephpleague.com/1.0/api/quick-reference/, (*16)

Additionally, you can setup presets and use them as a quicker way to apply manipulations to the images:, (*17)

// config/clyde.php
'presets' => [
    [
        'thumbnail' => [
            'w' => 100,
            'h' => 100,
            'fit' => 'crop'
        ]
    ]
],
<img src="{{ ClydeImage::url('56a1472beca5d.jpg', 'thumbnail') }}">

Watermarks

Watermarks are stored on the local filesystem by default. To use watermarks put the watermark files in storage/app/watermarks directory. To adjust the location where watermark files are stored you can edit watermarks and watermarks_path_prefix entries in the config., (*18)

ClydeImage::url('56a1472beca5d.jpg', [
    'mark' => 'watermark.png',
    'markpos' => 'top-right',
    'markw' => '50',
    'markh' => '50',
    'markpad' => '10'
]);

Security

All URLs generated by Clyde are signed by default. This means that there is always a signature appended to all URLs and verified when an image is displayed. To turn this feature off set the secure_urls key to false in the config (not recommended)., (*19)

Clyde?

The package name is a tribute to Clyde "The Glide" Drexler., (*20)

The Versions

18/02 2016

v0.0.5

0.0.5.0 https://github.com/antennaio/laravel-clyde

Image uploads and manipulation for Laravel, a wrapper around Glide

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kazik

laravel cache php upload resize images glide

02/02 2016

v0.0.4

0.0.4.0 https://github.com/antennaio/laravel-clyde

Image uploads and manipulation for Laravel, a wrapper around Glide

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kazik

laravel cache php upload resize images glide

23/01 2016

v0.0.3

0.0.3.0 https://github.com/antennaio/laravel-clyde

Image uploads and manipulation for Laravel, a wrapper around Glide

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kazik

laravel cache php upload resize images glide

23/01 2016

v0.0.2

0.0.2.0 https://github.com/antennaio/laravel-clyde

Image uploads and manipulation for Laravel, a wrapper around Glide

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kazik

laravel images uploads

22/01 2016

v0.0.1

0.0.1.0 https://github.com/antennaio/laravel-clyde

Image uploads and manipulation for Laravel, a wrapper around Glide

  Sources   Download

MIT

The Requires

 

The Development Requires

by Kazik

laravel images uploads