2amigos / yii2-file-upload-widget

BlueImp File Upload Widget for Yii2
Other
251 stars 140 forks source link

No thumbnail variable in custom view file #1

Closed 01011 closed 10 years ago

01011 commented 10 years ago

Hello. When i using custom view file, there is no $thumbnail. Probably, because missing line:

$params['thumbnail'] = $this->thumbnail;

in:

case static::STYLE_CUSTOM:
                if($this->customView === null) {
                    throw new InvalidConfigException(
                        '"FileInput::$customView" must be set if "FileInput::STYLE_CUSTOM" is used'
                    );
                }
                $view = $this->customView;
                break;
tonydspaniard commented 10 years ago

Do you mind sharing your code?

Thanks @01011

01011 commented 10 years ago

FileInput.php renderTemplate() method:

public function renderTemplate($field)
    {
        $params = ['field' => $field];
        switch($this->style)
        {
            case static::STYLE_INPUT:
                $view = $this->getViewPath() . '/inputField.php';
                break;
            case static::STYLE_BUTTON:
                $view = $this->getViewPath() . '/buttonField.php';
                break;
            case static::STYLE_IMAGE:
                $view = $this->getViewPath() . '/imageField.php';
                $params['thumbnail'] = $this->thumbnail;
                break;
            case static::STYLE_CUSTOM:
                if($this->customView === null) {
                    throw new InvalidConfigException(
                        '"FileInput::$customView" must be set if "FileInput::STYLE_CUSTOM" is used'
                    );
                }
                $view = $this->customView;
                $params['thumbnail'] = $this->thumbnail; // here
                break;
            default:
                throw new InvalidConfigException(
                    'Unrecognized "FileInput::$style" format. ' .
                    'It should be of "FileInput::STYLE_INPUT", "FileInput::STYLE_BUTTON", ' .
                    '"FileInput::STYLE_IMAGE" or "FileInput only.');
        }
        return $this->getView()->renderFile(Yii::getAlias($view), $params);
    }
tonydspaniard commented 10 years ago

@01011 I think you are on the wrong library: https://github.com/2amigos/yii2-file-input-widget

:)

01011 commented 10 years ago

@tonydspaniard yes, now i see )