ImageUploader.php 1.11 KB
<?php

namespace common\modules\file\widgets;
use yii\base\Widget;


class ImageUploader extends Widget
{
    public $height = 0;
    public $width = 0;
    public $field;
    public $file;
    public $model;
    public $multi = false;
    public $gallery;
    public $size;
    public $name = 'Add file...';
    public $remover = false;

    public function init(){

        parent::init();

    }


    public function run()
    {
        return $this->render('image_sizer',
            [
                'model'=>$this->model,
                'size' => $this->size,
                'field' => $this->field,
                'height' => $this->height,
                'width' => $this->width,
                'multi'  => $this->multi,
                'name'  => $this->name,
                'remover' => $this->remover
            ]);

    }

    public function getGallery(){
        if($this->gallery){
            $array = explode(",", $this->gallery);
            if(count($array) > 1){
                array_pop($array);
            }
            return $array;
        } else {
            return array();
        }

    }

}