PHPackages                             enstart/glide - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. enstart/glide

ActiveLibrary[Image &amp; Media](/categories/media)

enstart/glide
=============

Wrapper for Glide (on-demand image manipulation) for the enstart framework

0.1.0(9y ago)044MITPHPPHP &gt;=7.0

Since Jul 1Pushed 9y ago1 watchersCompare

[ Source](https://github.com/enstart/glide)[ Packagist](https://packagist.org/packages/enstart/glide)[ RSS](/packages/enstart-glide/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (2)Versions (3)Used By (0)

Enstart Extension: Glide
========================

[](#enstart-extension-glide)

Wrapper for Glide (on-demand image manipulation) for the enstart framework

### Dependencies:

[](#dependencies)

- `enstart/core` version 0.2+
- PHP 7.0+ with either the gd- or imagick library

### Install

[](#install)

```
composer require enstart/glide

```

### Config:

[](#config)

```
// Settings
'glide' => [
    'source'    => /path/to/upload/folder,
    'cache'     => /path/to/cache/folder',
],

// Register the service provider
'providers' => [
    ...
    'Enstart\Ext\Glide\ServiceProvider',
],

```

### Optional settings

[](#optional-settings)

There are a few optional settings as well:

```
'glide' => [
    // If you want to make sure that all resize-requests are from your app, you can
    // add a sign key. This prevents mass image-resize attacks
    'sign_key'  => 'a-128-bit-random-key',

    // The default driver is 'gd', but if you rather use imagick, simply change it
    'driver'    => 'imagick',

    // To set some presets (predefined manipulators) which you then access through `?p=thumb`
    'presets' => [
        'thumb' => [
            'w'   => 200,
            'h'   => 200,
            'fit' => 'crop',
        ],
    ],
]

```

To read more about settings for glide, visit [Glides documentation](http://glide.thephpleague.com/1.0/config/setup/). This package just passes the `glide`-config to Glide, so anything in the Glide doc will work here as well.

### Access the extension

[](#access-the-extension)

```
// Get a copy of the instance
$glide = $app->container->make('Enstart\Ext\Glide\Glide');

// or through the alias:
$app->glide

// or through dependency injection (if you type hint it in your constructor)
use Enstart\Ext\ImageResize\Glide;

```

### Get a link to a resized image

[](#get-a-link-to-a-resized-image)

In your code:

```
$url = $app->glide->getResizedImage('/path/to/image.jpg', [
    'w'   => 200,
    'h'   => 200,
    'fit' => crop
]);

// or through a preset
$url = $app->glide->getResizedImage('/path/to/image.jpg', ['p' => 'thumb']);

// alternative preset request
$url = $app->glide->getResizedImage('/path/to/image.jpg', 'thumb');

```

### View helpers

[](#view-helpers)

When you're in a view, you can use the view helper:

```
