PHP code example of daikazu / laravel-glider
1. Go to this page and download the library: Download daikazu/laravel-glider library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
daikazu / laravel-glider example snippets
use Daikazu\LaravelGlider\Facades\Glider;
// Generate URL
$url = Glider::url('photo.jpg', ['w' => 400, 'q' => 85]);
'presets' => [
'thumbnail' => ['w' => 150, 'h' => 150, 'fit' => 'crop'],
'hero' => ['w' => 1200, 'h' => 600, 'fit' => 'crop', 'q' => 90],
],
'background_presets' => [
'hero' => [
'xs' => ['w' => 768, 'h' => 400, 'fit' => 'crop'],
'md' => ['w' => 1024, 'h' => 500, 'fit' => 'crop'],
'lg' => ['w' => 1440, 'h' => 600, 'fit' => 'crop'],
],
],
return [
'source' => resource_path('assets'),
'cache' => storage_path('app/glider-cache'),
'base_url' => 'img',
'max_image_size' => 2000 * 2000,
'driver' => 'gd', // or 'imagick'
'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],
],
],
];
'cache' => ['disk' => 's3', 'prefix' => 'glider-cache'],
// config/glider.php
'secure' => env('GLIDER_SECURE', true),
// config/glider.php
'on_the_fly' => env('GLIDER_ON_THE_FLY', true),
// config/glider.php
'restrict_to_presets' => env('GLIDER_RESTRICT_TO_PRESETS', false),
// Ensure images are within intended directories
'source' => resource_path('assets/images'),
// config/glider.php
'max_image_size' => 2000 * 2000, // Prevent memory exhaustion
bash
php artisan vendor:publish --tag="glider-config"
bash
php artisan glider:build
bash
php artisan glider:build
bash
# deploy script (optional but recommended)
php artisan glider:build
bash
# deploy command
php artisan glider:build
❌ ../../../etc/passwd
❌ /var/www/../../etc/shadow
❌ image.jpg%00.php
❌ symlink-to-sensitive-dir/file.jpg