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\Glide;

// Generate a URL for a resized image
$url = Glide::getUrl('path/to/image.jpg', ['w' => 400, 'h' => 300]);

// Generate a URL with quality and format settings
$url = Glide::getUrl('image.jpg', [
    'w' => 800,
    'q' => 85,
    'fm' => 'webp'
]);

// config/glider.php
'presets' => [
    'thumbnail' => ['w' => 150, 'h' => 150, 'fit' => 'crop'],
    'hero' => ['w' => 1200, 'h' => 600, 'fit' => 'crop', 'q' => 90],
    'card' => ['w' => 400, 'h' => 250, 'fit' => 'crop'],
],

// config/glider.php
'background_presets' => [
    'hero' => [
        'xs' => ['w' => 768, 'h' => 400, 'fit' => 'crop'],
        'md' => ['w' => 1024, 'h' => 500, 'fit' => 'crop'], 
        'lg' => ['w' => 1440, 'h' => 600, 'fit' => 'crop'],
        'xl' => ['w' => 1920, 'h' => 700, 'fit' => 'crop'],
    ],
    'banner' => [
        'xs' => ['w' => 768, 'h' => 200, 'fit' => 'crop'],
        'lg' => ['w' => 1440, 'h' => 300, 'fit' => 'crop'],
    ],
],

return [
    // Source filesystem path
    'source' => resource_path('assets'),
    
    // Cache filesystem path  
    'cache' => storage_path('cache/glide'),
    
    // Watermarks filesystem path
    'watermarks' => resource_path('assets/watermarks'),
    
    // Route base URL
    'base_url' => 'img',
    
    // Maximum image size (pixels)
    'max_image_size' => env('GLIDE_MAX_IMAGE_SIZE', 2000 * 2000),
    
    // Image manipulation driver
    'driver' => env('IMAGE_MANIPULATION_DRIVER', 'imagick'),
    
    // Include file extensions in cache filenames
    'cache_with_file_extensions' => false,
    
    // Default manipulation parameters
    'defaults' => ['fm' => 'webp'],
    
    // Predefined manipulation presets
    'presets' => [
        'xs'  => ['w' => 320],
        'sm'  => ['w' => 480],
        'md'  => ['w' => 768],
        'lg'  => ['w' => 1280],
        'xl'  => ['w' => 1440],
        '2xl' => ['w' => 1000],
    ],
    
    // Responsive background image presets
    'background_presets' => [
        'hero' => [
            'xs' => ['w' => 768, 'h' => 400, 'fit' => 'crop'],
            'lg' => ['w' => 1440, 'h' => 600, 'fit' => 'crop'],
        ],
        'banner' => [
            'xs' => ['w' => 768, 'h' => 200, 'fit' => 'crop'],
            'lg' => ['w' => 1440, 'h' => 300, 'fit' => 'crop'],
        ],
    ],
];
bash
php artisan vendor:publish --tag="laravel-glider-config"
bash
php artisan vendor:publish --tag="laravel-glider-views"
bash
php artisan glide:clear-cache
bash
php artisan glide:convert-tags
bash
composer analyse