PHP code example of hkhasib / laravel-shortpixel

1. Go to this page and download the library: Download hkhasib/laravel-shortpixel 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/ */

    

hkhasib / laravel-shortpixel example snippets


Hkhasib\LaravelShortPixel\LaravelShortPixelServiceProvider::class,

'LaravelShortPixel' => Hkhasib\LaravelShortPixel\Facades\LaravelShortPixel::class,

    return [
    #other providers
    \Hkhasib\LaravelShortPixel\LaravelShortPixelServiceProvider::class,
];

    $middleware->alias([
            #other aliases
           'LaravelShortPixel'=>\Hkhasib\LaravelShortPixel\Facades\LaravelShortPixel::class,
        ]);

//optimize with refresh
$result = LaravelShortPixel::fromUrls('https://your.site/img/unoptimized.png', '/path/to/save/to', 'filename.png', $compression_level = 1, $width = 200, $height = 200, $maxDimension = true, $refresh=true]);


$result = LaravelShortPixel::refreshfromUrls('https://your.site/img/unoptimized.png', '/path/to/save/to', 'filename.png', $compression_level = 1, $width = 200, $height = 200, $maxDimension = true

php artisan vendor:publish --provider="Hkhasib\LaravelShortPixel\LaravelShortPixelServiceProvider"