About ¶
The lireincore/imgcache integration for Yii2 framework.
Requirements ¶
Install ¶
Add the "lireincore/yii2-imgcache": "~0.3.0"
package to your require
section in the composer.json
file
or
$ php composer.phar require lireincore/yii2-imgcache
Usage ¶
To use this extension, you need to create the imgcache.php
file in your config
folder and add this code:
<?php
return [
'srcdir' => '@app/files/uploads',
'destdir' => '@webroot/thumbs',
'webdir' => '@webroot',
'baseurl' => '@web',
//....
'presets' => [
'origin' => [
'effects' => [
//add the effects you need
//....
],
],
],
];
See lireincore/imgcache
README.md for more information about the available effects and other config options.
Also add the following code in your Yii2 application configuration:
$config = [
//....
'components' => [
//....
'imgcache'=> [
'class' => \LireinCore\Yii2ImgCache\ImgCache::class,
'config' => require(__DIR__ . '/imgcache.php'),
],
],
];
Use in your code:
//get thumb url for image '{srcdir}/blog/image.jpg' (preset 'origin')
$url = \Yii::$app->imgcache->url('blog/image.jpg', 'origin');
See lireincore/imgcache
README.md for more information about the available functions.
Resources ¶
License ¶
The MIT License (MIT). Please see License File for more information.
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.