maddoger/yii2-imagecache

此包的最新版本(v1.2.0)没有提供许可证信息。

Yii2的ImageCache扩展。

安装: 79

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 1

开放问题: 0

类型:yii2-extension

v1.2.0 2015-04-14 15:22 UTC

This package is not auto-updated.

Last update: 2024-09-14 17:26:36 UTC


README

安装

安装此扩展的首选方式是通过composer

运行以下命令之一:

php composer.phar require --prefer-dist maddoger/yii2-imagecache "*"

或者将以下内容添加到你的composer.json文件的require部分:

"maddoger/yii2-imagecache": "*"

#组件

'imageCache' => [
    'class' => 'maddoger\imagecache\ImageCache',
    'generateWithUrl' => false,
    'actionSavesFile' => false,

    //Avatar
    'presets' => [
        '100x100' => [
            'fit' => [
                'width' => 100,
                'height' => 100,
            ],
        ],
        '200x' => [
            'thumbnail' => [
                'width' => 200,
                'height' => 200,
            ],
        ],
    ],
],

#用于服务器生成

##在控制器中

public function actions()
    {
        return [
            'imagecache' => [
                'class' => 'maddoger\imagecache\ImageAction',
            ],
        ];
    }

##在配置中

'urlManager' => [
    ...
    'rules' => [
        ...
        'static/ic/<img:.*?>' => 'site/imagecache',
        ...
    ],
    ...
],

##.htaccess

RewriteEngine On

RedirectMatch 403 /\.
RedirectMatch 403 /\.htaccess$

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/static/ic/*
RewriteRule ^(.*)$  ../index.php [QSA,L]

#快速生成

##独立的php脚本

使用服务器文件夹中的文件。

为了快速生成,你可以使用服务器文件夹中的文件(.htaccess和生成脚本),或者使用其他方法。