2017 © Pedro Peláez
 

yii2-extension yii2-smart-image-field

Image upload field for Yii2 forms

image

mmedojevicbg/yii2-smart-image-field

Image upload field for Yii2 forms

  • Friday, February 12, 2016
  • by mmedojevicbg
  • Repository
  • 1 Watchers
  • 4 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 7 % Grown

The README.md

Smart Image Field - Yii2 extension

This is replacement of classic file upload HTML form element. Advantages of this field are: * You don't have to handle file upload yourself. It is encapsulated in ImageUploadAction. * ImageUploadAction resolves upload name clashes by default. * If existing model is edited, image field is pre-populated. * Uploaded image won't be lost if form has validation errors after submit. * There is a delete image link besides upload button., (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist mmedojevicbg/yii2-smart-image-field "dev-master"

or add, (*4)

"mmedojevicbg/yii2-smart-image-field": "dev-master"

to the require section of your composer.json file., (*5)

Usage

1) Attach ImageUploadAction to designated controller, (*6)

class SiteController extends BaseController
{
    function actions()
    {
        return [
            'upload' => [
                'class' => 'mmedojevicbg\SmartImageField\ImageUploadAction',
                'uploadsPath' => \Yii::getAlias('@webroot') . '/uploads',
                'uploadsUrl' => '/uploads'
            ]
        ];
    }
}

2) Utilize SmartImageField inside ActiveForm, (*7)

echo SmartImageField::widget(['model' => $model,
                              'attribute' => 'profile_image',
                              'uploadsHandler' => '/site/upload']);

The Versions

12/02 2016

dev-master

9999999-dev

Image upload field for Yii2 forms

  Sources   Download

GPL-3.0+

The Requires

 

by Marko Medojevic

extension yii2 form upload image