PHP code example of lireincore / yii2-imgcache

1. Go to this page and download the library: Download lireincore/yii2-imgcache 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/ */

    

lireincore / yii2-imgcache example snippets




return [
    'srcdir' => '@app/files/images',
    'destdir' => '@webroot/thumbs',
    'webdir' => '@webroot',
    'baseurl' => '@web',
    //....
    'presets' => [
        'origin' => [
            'effects' => [
                //add the effects you need
                //....
            ],
        ],
    ],
];

$config = [
    //....
    'container' => [
        //....
        'singletons'  => [
            //....
            LireinCore\Yii2ImgCache\ImgCache::class => [
                ['class' => LireinCore\Yii2ImgCache\ImgCache::class],
                [
                    

use LireinCore\Yii2ImgCache\ImgCache;

$imgCache = Yii::$container->get(ImgCache::class);

// get thumb url for image '{srcdir}/blog/image.jpg' (preset 'origin')
$url = $imgcache->url('blog/image.jpg', 'origin');


// get thumb url for image '{srcdir}/blog/image.jpg' (preset 'origin')
$url = \Yii::$app->imgcache->url('blog/image.jpg', 'origin');
 bash
$ php composer.phar