| Recommend this page to a friend! | 
| Info | Documentation | Reputation | Support forum | Blog | Links | 
| Ratings | Unique User Downloads | Download Rankings | ||||
| Not enough user ratings | Total: 21 | All time:  11,324 This week: 73 | ||||
| Version | License | PHP version | Categories | |||
| yii2-thumbnailer 1.0.0 | Custom (specified... | 5 | PHP 5, Graphics, Libraries | 
| Description | Author  | |
This class can generate a thumbnail image given the image URL.  | 
Yii2 component to generate image thumnails of any size.
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist daxslab/yii2-thumbnailer "*"
or add
"daxslab/yii2-thumbnailer": "*"
to the require section of your composer.json file.
The basic configuration only requires adding the component to the application:
'components' => [
    //...
    'thumbnailer' => [
        'class' => 'daxslab\thumbnailer\Thumbnailer',
    ],
    //...
]
Besides that a default value is always provided, all the options can be configured.
'components' => [
    //...
    'thumbnailer' => [
        'class' => 'daxslab\thumbnailer\Thumbnailer',
        'defaultWidth' => 500,
        'defaultHeight' => 500,
        'thumbnailsBasePath' => '@webroot/assets/thumbs',
        'thumbnailsBaseUrl' => '@web/assets/thumbs',
        'enableCaching' => true, //defaults to false but is recommended
    ],
    //...
]
Once the extension is configured, simply use it in your views by:
//Generates thumbnail with default values specified in the configuration
Html::img(Yii::$app->thumbnailer->get($imageUrl));
//Generates a 400px width thumbnail. The height is determined as the width because is not set. 
Html::img(Yii::$app->thumbnailer->get($imageUrl, 400));
//Generates a 400x400 pixels thumbnail and 60% quality 
Html::img(Yii::$app->thumbnailer->get($imageUrl, 400, 400));
//Generates a 400x400 pixels thumbnail and 10% quality
Html::img(Yii::$app->thumbnailer->get($imageUrl, 400, 400, 10));
//Generates a 400x400 pixels thumbnail, 10% quality and not cropping the image
//but inserting it into a box with the specified dimensions.
Html::img(Yii::$app->thumbnailer->get($imageUrl, 400, 400, 10, ManipulatorInterface::THUMBNAIL_INSET));
Proudly made by Daxslab.
| File | Role | Description | 
|---|---|---|
| Data | Auxiliary data | |
| Data | Auxiliary data | |
| Lic. | License text | |
| Doc. | Documentation | |
| Class | Class source | 
| The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. | 
| Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
| 100% | 
  | 
  | 
| Applications that use this package | 
 If you know an application of this package, send a message to the author to add a link here.