PHPackages                             daikazu/laravel-glider - 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. [Templating &amp; Views](/categories/templating)
4. /
5. daikazu/laravel-glider

ActiveLibrary[Templating &amp; Views](/categories/templating)

daikazu/laravel-glider
======================

Start using Glide on-the-fly instantly in your Laravel blade templates.

v3.3.1(1mo ago)882.3k—8.3%3MITPHPPHP ^8.3CI passing

Since Dec 24Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/daikazu/laravel-glider)[ Packagist](https://packagist.org/packages/daikazu/laravel-glider)[ Docs](https://github.com/daikazu/laravel-glider)[ GitHub Sponsors](https://github.com/Daikazu)[ RSS](/packages/daikazu-laravel-glider/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (32)Versions (29)Used By (0)

  ![Logo for Glider](art/header-light.png)[![Latest Version on Packagist](https://camo.githubusercontent.com/e313658cd13333747ef7ff0b57a1c797ad10bdaae666b92b0605643919e4b99d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6461696b617a752f6c61726176656c2d676c696465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daikazu/laravel-glider)[![GitHub Tests Action Status](https://camo.githubusercontent.com/3dc6fd34558c041debf524a121d6c8e4d35c8262f66e17edc81b31cbfb36a968/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6461696b617a752f6c61726176656c2d676c696465722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/daikazu/laravel-glider/actions?query=workflow%3Arun-tests+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/676e41ec47d4c152a5a251fd8af205bddb25a5c73dbb0720db6c3fd67c1b0d01/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6461696b617a752f6c61726176656c2d676c696465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/daikazu/laravel-glider)

Laravel Glider
==============

[](#laravel-glider)

On-the-fly image manipulation for Laravel using [League/Glide](https://glide.thephpleague.com/). Transform, optimize, and serve images with elegant Blade components.

Features
--------

[](#features)

- **On-demand Processing** - Transform images via URL parameters
- **Responsive Images** - Automatic srcset and responsive backgrounds
- **Remote Images** - Process external URLs with caching
- **Secure URLs** - Signed URLs prevent unauthorized manipulation
- **Performance** - Built-in caching layer
- **Blade Components** - Clean syntax for templates
- **Presets** - Reusable image configurations

Installation
------------

[](#installation)

```
composer require daikazu/laravel-glider
```

Publish configuration:

```
php artisan vendor:publish --tag="glider-config"
```

The cache directory is created automatically with `.gitignore` added.

Quick Start
-----------

[](#quick-start)

### Basic Image

[](#basic-image)

```

```

### Responsive Image

[](#responsive-image)

```

```

### Background Image

[](#background-image)

```

    Welcome

```

### Responsive Background

[](#responsive-background)

```

    Content

```

### Using the Facade

[](#using-the-facade)

```
use Daikazu\LaravelGlider\Facades\Glide;

// Generate URL
$url = Glide::url('photo.jpg', ['w' => 400, 'q' => 85]);
```

Usage Guide
-----------

[](#usage-guide)

### Image Manipulation

[](#image-manipulation)

All [Glide parameters](https://glide.thephpleague.com/3.0/api/quick-reference/) are supported with the `glide-` prefix:

**Sizing**

```

```

**Quality &amp; Format**

```

```

**Effects**

```

```

### Focal Points

[](#focal-points)

Control image positioning within its container using CSS:

```

    Content

```

**Available positions:** `center`, `top`, `bottom`, `left`, `right`, `top-left`, `top-right`, `bottom-left`, `bottom-right`

**How it works:**

- For ``: Applies `object-fit: cover` and `object-position`
- For backgrounds: Sets `background-position` in CSS
- For server-side cropping, use `glide-fit="crop-top"` or `glide-fit="crop-25-75"`

### Presets

[](#presets)

Define reusable configurations in `config/laravel-glider.php`:

```
'presets' => [
    'thumbnail' => ['w' => 150, 'h' => 150, 'fit' => 'crop'],
    'hero' => ['w' => 1200, 'h' => 600, 'fit' => 'crop', 'q' => 90],
],
```

Use in components:

```

```

### Background Images

[](#background-images)

Create responsive backgrounds with automatic media queries:

```

        Hero Title

```

**Custom breakpoints:**

```

        Hero Title

```

**Background presets** in config:

```
'background_presets' => [
    'hero' => [
        'xs' => ['w' => 768, 'h' => 400, 'fit' => 'crop'],
        'md' => ['w' => 1024, 'h' => 500, 'fit' => 'crop'],
        'lg' => ['w' => 1440, 'h' => 600, 'fit' => 'crop'],
    ],
],
```

### Remote Images

[](#remote-images)

Process images from external URLs automatically:

```

```

Remote images are fetched, processed, and cached locally. Default config values apply automatically.

Components Reference
--------------------

[](#components-reference)

### ``

[](#x-glide-img)

Basic image with transformations.

**Attributes:**

- `src` - Image path (required)
- `focal-point` - CSS positioning (e.g., `top`, `75,25`)
- `glide-*` - Any Glide parameter (see [Parameters](#glide-parameters))
- Standard HTML `` attributes (alt, class, loading, etc.)

### ``

[](#x-glide-img-responsive)

Responsive image with automatic srcset generation.

**Attributes:**

- Same as ``
- Generates multiple sizes for different viewports

### ``

[](#x-glide-bg)

Background image container (non-responsive).

**Attributes:**

- `src` - Image path (required)
- `preset` - Background preset name
- `focal-point` - CSS positioning
- `position` - CSS background-position (default: `center`)
- `size` - CSS background-size (default: `cover`)
- `repeat` - CSS background-repeat (default: `no-repeat`)
- `attachment` - CSS background-attachment (default: `scroll`)
- `class` - CSS classes for container
- `glide-*` - Any Glide parameter

### ``

[](#x-glide-bg-responsive)

Responsive background with media queries.

**Attributes:**

- `src` - Image path (required)
- `preset` - Background preset name
- `breakpoints` - Custom breakpoint array
- `focal-point` - CSS positioning for all breakpoints
- `lazy` - Enable lazy loading
- `fallback` - Fallback image path
- `glide-*` - Any Glide parameter

Glide Parameters
----------------

[](#glide-parameters)

Common parameters (use `glide-` prefix in components):

ParameterValuesDescription`w`pixelsWidth`h`pixelsHeight`fit``crop`, `contain`, `fill`, `max`Resize mode`fit``crop-{position}`Crop with position (e.g., `crop-top`, `crop-center`)`fit``crop-{x}-{y}[-{zoom}]`Crop with focal point/zoom (e.g., `crop-25-75-2`)`q`1-100Quality`fm``jpg`, `png`, `webp`, `avif`Format`blur`0-100Blur amount`bri`-100 to 100Brightness`con`-100 to 100Contrast`filt``greyscale`, `sepia`FilterSee [full Glide documentation](https://glide.thephpleague.com/3.0/api/quick-reference/) for all parameters.

Artisan Commands
----------------

[](#artisan-commands)

**Clear image cache:**

```
php artisan glider:clear-cache
```

**Convert HTML img tags to components (WIP):**

```
php artisan glider:convert-img-tags --dry-run
```

Configuration
-------------

[](#configuration)

Key options in `config/laravel-glider.php`:

```
return [
    'source' => resource_path('assets'),
    'cache' => storage_path('app/glider-cache'),
    'base_url' => 'img',
    'max_image_size' => 2000 * 2000,
    'driver' => 'imagick', // or 'gd'

    'defaults' => ['fm' => 'webp', 'q' => 85],

    'presets' => [
        'thumbnail' => ['w' => 150, 'h' => 150, 'fit' => 'crop'],
    ],

    'background_presets' => [
        'hero' => [
            'xs' => ['w' => 768, 'h' => 400],
            'lg' => ['w' => 1440, 'h' => 600],
        ],
    ],
];
```

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 11.x or 12.x
- GD or Imagick extension
- League/Glide 3.x

Security
--------

[](#security)

Laravel Glider implements multiple security layers to protect your application from common attacks. These features work together to ensure safe image processing.

### URL Signing

[](#url-signing)

**Status:** Enabled by default (`GLIDE_SECURE=true`)

URL signing prevents unauthorized image manipulation and protects against denial-of-service attacks. When enabled, all image URLs are cryptographically signed using your application key.

```
// config/laravel-glider.php
'secure' => env('GLIDE_SECURE', true),
```

**Important:** URL signing should **NEVER** be disabled in production environments. Unsigned URLs allow attackers to:

- Generate infinite variations of images, exhausting server resources
- Perform expensive image operations repeatedly
- Fill disk space with cached attack images

The signing mechanism uses Laravel's `APP_KEY` by default. Ensure your application key is:

- Generated with `php artisan key:generate`
- Kept secure and never committed to version control
- Properly configured in production environments

### Path Traversal Protection

[](#path-traversal-protection)

Laravel Glider validates all file paths to prevent directory traversal attacks. The package automatically:

- **Validates path boundaries** - Ensures all paths resolve within the configured source directory
- **Blocks null bytes** - Prevents null byte injection attacks (`../../../etc/passwd%00.jpg`)
- **Prevents symlink attacks** - Validates real paths to stop symlink-based directory escapes
- **Sanitizes input** - Removes dangerous characters from file paths

Example of blocked attacks:

```
❌ ../../../etc/passwd
❌ /var/www/../../etc/shadow
❌ image.jpg%00.php
❌ symlink-to-sensitive-dir/file.jpg

```

These protections are automatic and require no configuration.

### XSS Protection

[](#xss-protection)

Background image components sanitize CSS values to prevent cross-site scripting attacks via CSS injection:

```

```

The package validates and sanitizes:

- `position` attributes
- `size` attributes
- `repeat` attributes
- `attachment` attributes
- `focal-point` values

### SSRF Protection

[](#ssrf-protection)

When processing remote images via URLs, Laravel Glider protects against Server-Side Request Forgery (SSRF) attacks:

```

❌ http://localhost/admin/secret.jpg
❌ http://127.0.0.1/internal/image.jpg
❌ http://192.168.1.1/router-config.jpg
❌ http://10.0.0.5/database-backup.jpg
❌ http://169.254.169.254/latest/meta-data (AWS metadata)
```

**Protections implemented:**

- **Blocks localhost access** - Prevents requests to `localhost`, `127.0.0.1`, `::1`, and `0.0.0.0`
- **Blocks private IP ranges** - Rejects RFC1918 private addresses (10.x.x.x, 172.16-31.x.x, 192.168.x.x)
- **Blocks link-local addresses** - Prevents access to 169.254.x.x range (cloud metadata endpoints)
- **Blocks dangerous ports** - Rejects connections to common internal service ports (SSH:22, MySQL:3306, Redis:6379, etc.)
- **Validates URL schemes** - Only allows `http://` and `https://` protocols
- **DNS resolution validation** - Resolves hostnames to IPs and validates against private ranges

These protections prevent attackers from:

- Scanning internal network infrastructure
- Accessing cloud provider metadata endpoints
- Reaching internal services and databases
- Port scanning internal systems
- Bypassing firewall rules via your server

All SSRF protections are automatic and require no configuration.

### Security Best Practices

[](#security-best-practices)

Follow these recommendations to maintain secure image processing:

1. **Keep URL signing enabled**

    ```
    # .env (production)
    GLIDE_SECURE=true
    ```
2. **Use a strong application key**

    ```
    # Generate a secure key
    php artisan key:generate
    ```
3. **Validate source paths**

    ```
    // Ensure images are within intended directories
    'source' => resource_path('assets/images'),
    ```
4. **Limit maximum image dimensions**

    ```
    // config/laravel-glider.php
    'max_image_size' => 2000 * 2000, // Prevent memory exhaustion
    ```
5. **Keep the package updated**

    ```
    composer update daikazu/laravel-glider
    ```
6. **Use HTTPS in production**

    - Protects signed URLs from interception
    - Prevents man-in-the-middle attacks on image requests
7. **Configure appropriate cache permissions**

    ```
    # Ensure cache directory has proper permissions
    chmod 755 storage/app/glider-cache
    ```

### Reporting Security Issues

[](#reporting-security-issues)

If you discover a security vulnerability, please email \[\] or use the [GitHub Security Advisory](https://github.com/daikazu/laravel-glider/security) feature. Do not create public issues for security vulnerabilities.

Testing
-------

[](#testing)

```
composer test          # Run tests
composer test-coverage # With coverage
composer analyse       # Static analysis
```

Resources
---------

[](#resources)

- [Changelog](CHANGELOG.md)
- [League/Glide Documentation](https://glide.thephpleague.com/)
- [Report Security Issues](https://github.com/daikazu/laravel-glider/security)

Credits
-------

[](#credits)

- [Mike Wall](https://github.com/daikazu)
- [All Contributors](https://github.com/daikazu/laravel-glider/contributors)

License
-------

[](#license)

MIT License. See [LICENSE.md](LICENSE.md) for details.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance89

Actively maintained with recent releases

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 92.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~67 days

Recently: every ~42 days

Total

24

Last Release

55d ago

Major Versions

v0.1.0-alpha → v1.0.02021-12-24

v1.0.8 → v2.0.02022-02-24

v2.0.2 → v3.0.02025-08-20

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4039367?v=4)[Mike Wall](/maintainers/daikazu)[@daikazu](https://github.com/daikazu)

---

Top Contributors

[![daikazu](https://avatars.githubusercontent.com/u/4039367?v=4)](https://github.com/daikazu "daikazu (100 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelbladeglidelaravel-glidedaikazuGliderlaravel-glider

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/daikazu-laravel-glider/health.svg)

```
[![Health](https://phpackages.com/badges/daikazu-laravel-glider/health.svg)](https://phpackages.com/packages/daikazu-laravel-glider)
```

###  Alternatives

[spatie/laravel-blade-comments

Add debug comments to your rendered output

177325.5k](/packages/spatie-laravel-blade-comments)[ryangjchandler/blade-capture-directive

Create inline partials in your Blade templates with ease.

8222.2M12](/packages/ryangjchandler-blade-capture-directive)[ralphjsmit/laravel-glide

Auto-magically generate responsive images from static image files.

4719.6k5](/packages/ralphjsmit-laravel-glide)[angus-mcritchie/blade-boost-directive

Lightning-Fast Blade Components with `@boost` Directive

3910.0k](/packages/angus-mcritchie-blade-boost-directive)[combindma/dash-ui

A streamlined and stylish UI component library for Laravel Blade, crafted with TailwindCSS and AlpineJs for simplicity and elegance.

631.4k](/packages/combindma-dash-ui)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
