Download the PHP package unrulynatives/laravel-glider without Composer
On this page you can find all versions of the php package unrulynatives/laravel-glider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download unrulynatives/laravel-glider
More information about unrulynatives/laravel-glider
Files in unrulynatives/laravel-glider
Package laravel-glider
Short Description Start using Glide on-the-fly instantly in your Laravel blade templates.
License MIT
Homepage https://github.com/daikazu/laravel-glider
Informations about the package laravel-glider
Laravel Glider
On-the-fly image manipulation for Laravel using League/Glide. Transform, optimize, and serve images with elegant Blade components.
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
Publish configuration:
The cache directory is created automatically with .gitignore added.
Quick Start
Basic Image
Responsive Image
Background Image
Responsive Background
Using the Facade
Usage Guide
Image Manipulation
All Glide parameters are supported with the glide- prefix:
Sizing
Quality & Format
Effects
Focal Points
Control image positioning within its container using CSS:
Available positions: center, top, bottom, left, right, top-left, top-right, bottom-left, bottom-right
How it works:
- For
<img>: Appliesobject-fit: coverandobject-position - For backgrounds: Sets
background-positionin CSS - For server-side cropping, use
glide-fit="crop-top"orglide-fit="crop-25-75"
Presets
Define reusable configurations in config/laravel-glider.php:
Use in components:
Background Images
Create responsive backgrounds with automatic media queries:
Custom breakpoints:
Background presets in config:
Remote Images
Process images from external URLs automatically:
Remote images are fetched, processed, and cached locally. Default config values apply automatically.
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)- Standard HTML
<img>attributes (alt, class, loading, etc.)
<x-glide-img-responsive>
Responsive image with automatic srcset generation.
Attributes:
- Same as
<x-glide-img> - Generates multiple sizes for different viewports
<x-glide-bg>
Background image container (non-responsive).
Attributes:
src- Image path (required)preset- Background preset namefocal-point- CSS positioningposition- 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 containerglide-*- Any Glide parameter
<x-glide-bg-responsive>
Responsive background with media queries.
Attributes:
src- Image path (required)preset- Background preset namebreakpoints- Custom breakpoint arrayfocal-point- CSS positioning for all breakpointslazy- Enable lazy loadingfallback- Fallback image pathglide-*- Any Glide parameter
Glide Parameters
Common parameters (use glide- prefix in components):
| Parameter | Values | Description |
|---|---|---|
w |
pixels | Width |
h |
pixels | Height |
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-100 | Quality |
fm |
jpg, png, webp, avif |
Format |
blur |
0-100 | Blur amount |
bri |
-100 to 100 | Brightness |
con |
-100 to 100 | Contrast |
filt |
greyscale, sepia |
Filter |
See full Glide documentation for all parameters.
Artisan Commands
Clear image cache:
Convert HTML img tags to components (WIP):
Configuration
Key options in config/laravel-glider.php:
Requirements
- PHP 8.3+
- Laravel 11.x or 12.x
- GD or Imagick extension
- League/Glide 3.x
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
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.
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
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:
These protections are automatic and require no configuration.
XSS Protection
Background image components sanitize CSS values to prevent cross-site scripting attacks via CSS injection:
The package validates and sanitizes:
positionattributessizeattributesrepeatattributesattachmentattributesfocal-pointvalues
SSRF Protection
When processing remote images via URLs, Laravel Glider protects against Server-Side Request Forgery (SSRF) attacks:
Protections implemented:
- Blocks localhost access - Prevents requests to
localhost,127.0.0.1,::1, and0.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://andhttps://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
Follow these recommendations to maintain secure image processing:
-
Keep URL signing enabled
-
Use a strong application key
-
Validate source paths
-
Limit maximum image dimensions
-
Keep the package updated
-
Use HTTPS in production
- Protects signed URLs from interception
- Prevents man-in-the-middle attacks on image requests
- Configure appropriate cache permissions
Reporting Security Issues
If you discover a security vulnerability, please email [[email protected]] or use the GitHub Security Advisory feature. Do not create public issues for security vulnerabilities.
Testing
Resources
Credits
License
MIT License. See LICENSE.md for details.
All versions of laravel-glider with dependencies
illuminate/contracts Version ^11.0||^12.0||^13.0
league/glide Version ^3.0
ntzrbtr/flysystem-http Version ^2.0
spatie/laravel-package-tools Version ^1.16