xtracode/yii2-image 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

xtracode/yii2-image

Composer 安装命令:

composer require xtracode/yii2-image

包简介

Yii2 image module

README 文档

README

License Latest Stable Version Latest Unstable Version Total Downloads

Yii2 module for image manipulating.

Documentation is at docs/guide/README.md.

Features

  • image upload
  • display image widget
  • watermark (text and image)
  • image resize on demand

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require "xtracode/yii2-image" "dev-master"

or add

"xtracode/yii2-image" : "dev-master"

to the require section of your application's composer.json file.

Configuration

  • Add module to config section:
'modules' => [
    'image' => [
        'class' => 'xtracode\yii2-image\ImageModule'
    ]
]
  • Run migrations:
php yii migrate --migrationPath=@xtracode/yii2-image/migrations

Usage

  • Add actions to your controller:
public function actions()
{
    return [
        'delete-image' => [
            'class' => '\xtracode\image\actions\DeleteImageAction',
        ],
        'main-image' => [
            'class' => '\xtracode\image\actions\MainImageAction',
        ],
    ];
}

Upload multiple image

Use method $model->uploadSingleImage() in controller:

public function actionCreate()
{
    $model = new Article;

    if ($model->load($_POST) && $model->save()) {
        $model->uploadImage();

        \Yii::$app->session->setFlash('success', \Yii::t('article', 'Article successfully saved'));
        return $this->redirect(['view', 'id' => $model->id]);
    } else {
        return $this->render('create', [
            'model' => $model,
        ]);
    }
}

In view:

<div class="col-sm-offset-1">
    <?= \xtracode\image\widgets\ImageList::widget([
        'model' => $model,
        'model_id' => $model->id,
    ]) ?>
</div>

Upload single image

use method $model->uploadSingleImage() in controller:

public function actionCreate()
{
    $model = new Article;

    if ($model->load($_POST) && $model->save()) {
        $model->uploadSingleImage();

        \Yii::$app->session->setFlash('success', \Yii::t('article', 'Article successfully saved'));
        return $this->redirect(['view', 'id' => $model->id]);
    } else {
        return $this->render('create', [
            'model' => $model,
        ]);
    }
}

In view:

<div class="col-sm-offset-1">
    <?= \xtracode\image\widgets\ImageList::widget([
        'model' => $model,
        'model_id' => $model->id,
    ]) ?>
</div>

For more details see the guide.

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-08-28

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固