alkurn / yii2-thumbnail
Yii2 helper for creating and caching thumbnails on real time
Package info
github.com/alkurn/yii2-thumbnail
Type:yii2-extension
pkg:composer/alkurn/yii2-thumbnail
dev-master
2022-05-05 04:14 UTC
Requires
This package is not auto-updated.
Last update: 2026-03-19 21:47:56 UTC
README
Yii2 helper for creating and caching thumbnails on real time.
Installation
The preferred way to install this extension is through composer.
- Either run
php composer.phar require --prefer-dist "alkurn/yii2-thumbnail" "dev-master"
or add
"alkurn/yii2-thumbnail" : "*"
to the require section of your application's composer.json file.
- Add a new lines in
bootstrapfile of your application, for example:
Yii::setAlias('@uploads', dirname(dirname(__DIR__)) . '/uploads');
Yii::setAlias('@cache', dirname(dirname(__DIR__)) . '/uploads/cache');
Yii::setAlias('@image', '/uploads/cache');
- Add a new component in
componentssection of your application's configuration file (optional), for example:
'components' => [ 'thumbnail' => [ 'class' => 'alkurn\thumbnail\Thumbnail', 'cacheAlias' => Yii::getAlias('@cache/'), 'uploadsAlias' => Yii::getAlias('@uploads/'), 'imageAlias' => Yii::getAlias('@image/'), 'defaultImage' => 'default.png', ], ],
and in bootstrap section, for example:
'bootstrap' => ['log', 'thumbnail'],
It is necessary if you want to set global helper's settings for the application.
Usage
For example:
use alkurn\thumbnail\ThumbnailImage; echo ThumbnailImage::thumbnailImg( $model->image, 50, 50, ThumbnailImage::THUMBNAIL_OUTBOUND, ['alt' => $model->image] );