PHP code example of andrewdanilov / yii2-thumbs

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

    

andrewdanilov / yii2-thumbs example snippets


$src = \andrewdanilov\thumbs\Thumb::widget([
    'image' => '/images/img.png', // Image to resize and cache relative to base site uri
    'sizes' => '100x100', // Optional. Result image sizes. String devided with 'x' or array with 'width' and 'height' keys. Default is '100x100'
    'zc' => true, // Optional. Zoom and crop. Default is true.
    'quality' => 90, // Optional. Jpeg quality from 1 to 100. Default is 90
    'backgroundColor' => 'transparent', // Optional. Values like 'transparent', 'FFF', '000000'. Default is 'transparent'
    'noImageUri' => '/images/noimg.png', // Optional. Path to image to use for empty or absent images relative to base site uri
    'cachePath' => '/assets/thumbs/', // Optional. Path to store cached images relative to base site uri. Default is '/assets/thumbs/'
    'cacheTime' => 604800, // Optional. Time to chache in seconds. Default is 604800
]);
echo \yii\helpers\Html::img($src);

// width x height string notation
$sizes = '400x200';
$sizes = '400x';
$sizes = 'x200';
// array notation
$sizes = ['width' => 400, 'height' => 200];
$sizes = ['width' => 400];
$sizes = ['height' => 200];