ezsoft / yii2-glide
This package is abandoned and no longer maintained.
No replacement package was suggested.
This package has no released version yet, and little information is available.
README
ezsoft/yii2-glide 是一个集文件访问验证与图片文件编辑功能的类库.
主要用于解决ez6中个服务器被动同步文件内容和正常用户请求.
Usage
服务器端配置
'components' => [ ... 'glide' => [ 'class' => 'ezsoft\glide\components\Glide', 'sourcePath' => '@app/web/uploads', 'cachePath' => '@runtime/glide', 'signKey' => '<random-key>' // "false" 不使用验证 'allowUserAgents' => ['qiniu-imgstg-spider-1.0', 'ezsoft-auto-file-getter-1.0'],//开启验证后特例 ], ... ]
Then you can output modified image like so:
Yii::$app->glide->outputImage('new-upload.jpg', ['w' => 100, 'fit' => 'crop'])
You can also use trntv\glide\actions\GlideAction
to output images:
In any controller add (SiteController
for example):
public function actions() { return [ 'glide' => 'trntv\glide\actions\GlideAction' ] }
Than use it:
/index.php?r=site/glide?path=new-upload.jpg&w=100&h=75
Example
Complex Glide integration example can be found here
客户端
'controllerMap' => [ 'filegetter' => '\ezsoft\glide\controllers\GetterController', 'userAgent'=>'ezsoft-auto-file-getter-1.0' ], 'components' => [ ... 'urlManager' => [ 'class' => 'yii\web\UrlManager', 'enablePrettyUrl' => true, 'showScriptName' => false, 'rules' => [ ['pattern' => '<path:([\d]{4}/[\d]{2}/[\d]{2}/.*)>', 'route' => 'filegetter/index', 'encodeParams' => false, 'suffix' => ''], ] ], ... ]
配置后
访问当前应用域名/2017/02/03/foobar.png 判断文件是否存在 不存在,回服务器端获取该文件,存入缓存 返回文件给浏览器