定制 yii2mod/yii2-image 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

yii2mod/yii2-image

最新稳定版本:1.0.0

Composer 安装命令:

composer require yii2mod/yii2-image

包简介

Provides methods for the dynamic manipulation of images. Various image formats such as JPEG, PNG, and GIF can be resized, cropped, rotated.

README 文档

README

Yii2 Image Extension


Provides methods for the dynamic manipulation of images. Various image formats such as JPEG, PNG, and GIF can be resized, cropped, rotated.

Latest Stable Version Total Downloads License

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist yii2mod/yii2-image "*"

or add

"yii2mod/yii2-image": "*"

to the require section of your composer.json.

Configuration

Component Setup

To use the Image Component, you need to configure the components array in your application configuration:

'components' => [
    'image' => [
        'class' => 'yii2mod\image\ImageComponent',
    ],
],

Attach the behavior to the model

You need to add the ImageBehavior to the your model.

public function behaviors()
{
    return [
        'image' => [
            'class' => ImageBehavior::class,
            'pathAttribute' => 'path',
        ],
    ];
}

Action Setup

You need to add the ImageAction to the your controller.

public function actions()
{
    return [
        'image' => 'yii2mod\image\actions\ImageAction'
    ];
}

Configuring image types

Next, you should configure your params section in your configuration file:

'params' => [
    'image' => [
        'medium' => [
            'thumbnail' => [
                'box' => [194, 194],
                'mode' => 'outbound'
            ],
            'visible' => 'user', //checking role before outputing url
        ],
        'home' => [
            'thumbnail' => [
                'box' => [640, 480],
                'mode' => 'inset',
            ],
            'watermark' => [
                'watermarkFilename' => '@app/web/images/watermark.png',
            ],
        ],
    ],
],

Usage:

$model = Model::find()->one();
echo $model->url('medium'); // home is the type of photo.

Support us

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

统计信息

  • 总下载量: 10.37k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 27
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 25
  • Watchers: 6
  • Forks: 11
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2014-11-26