定制 sergeykoz/yii2-imageupload 二次开发

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

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

sergeykoz/yii2-imageupload

最新稳定版本:0.3.1

Composer 安装命令:

composer require sergeykoz/yii2-imageupload

包简介

Image upload widget with crop for Yii2

README 文档

README

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist sergeykoz/yii2-imageupload 

or add

"sergeykoz/yii2-imageupload": "0.3.1",

to the require section of your composer.json.

Usage

Add upload widget to a form

<?php use ssoft\imageupload\ImageUpload; echo $form = ActiveForm::begin(['id' => 'image-form', 'options' => ['enctype'=>'multipart/form-data']]); // first way echo ImageUpload::widget([ 'model' => $photoModel, 'attribute' => 'photo', 'parametersAttibute' => 'photo_parameters', 'addClass' => 'col-sm-8', 'imageUrl' => Yii::getAlias('@web') . '/files', 'imagePath' => Yii::getAlias('@webroot') . '/files', 'placeholder' => 'Photo', 'size' => ['height' => 300, 'width' => 100], 'aspectRatio' => 0.33, 'disabled' => false ]); // second way echo $form->field($photoModel, 'image')->widget(ImageUpload::className(), [ 'parametersAttibute' => 'image_parameters', 'imageUrl' => Yii::getAlias('@web') . '/files', 'imagePath' => Yii::getAlias('@webroot') . '/files', 'placeholder' => 'Image' ]); echo ActiveForm::end(); ?>

Configure main.php

'controllerMap' => [ 'imageupload' => 'ssoft\imageupload\ImageController', ],

Manage of uploaded images

<?php use ssoft\imageupload\Image; // create instance of the image $image = new Image([ 'imagePath' => Yii::getAlias('@webroot') . '/files', 'imageFile' => $photoModel->photo, 'parameters' => $photoModel->photo_parameters, ]); // save the image with size 100x300 with name Filename100x300.Ext $image->save( Yii::getAlias('@webroot') . '/files', Image::thumbnailName($photoModel->photo, ['height' => 300, 'width' => 100]), ['height' => 300, 'width' => 100] ); // get content of the image png echo $image->show('png', ['height' => 600, 'width' => 600]); ?>

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固