ImageUploadBehavior и GD sizeof(null)

Общие вопросы по использованию второй версии фреймворка. Если не знаете как что-то сделать и это про Yii 2, вам сюда.
Ответить
nulled
Сообщения: 74
Зарегистрирован: 2018.10.30, 13:42

ImageUploadBehavior и GD sizeof(null)

Сообщение nulled »

Привет, мучаю ImageUploadBehavior и
1) сначала: at line 64– PHPThumb\GD::setOptions(['width' => 400, 'height' => 300])
2) затем: GD.php at line 972– sizeof(null)
"Теперь при использовании count() с параметром, который нельзя посчитать будет возникать ошибка уровня E_WARNING (это также касается sizeof() как псевдонима этой функции)." :? Каким способом лучше это исправить?

ImageUploadBehavior

Код: Выделить всё

var_dump($config); //array(2) { ["width"]=> int(400) ["height"]=> int(300) }
$thumb = new GD($path, $config);
GD

Код: Выделить всё

 /**
     * The options for this class
     *
     * This array contains various options that determine the behavior in
     * various functions throughout the class.  Functions note which specific
     * option key / values are used in their documentation
     *
     * @var array
     */
    protected $options;

/**
     * @param string $fileName
     * @param array $options
     * @param array $plugins
     */
    public function __construct($fileName, $options = array(), array $plugins = array())
    {
        parent::__construct($fileName, $options, $plugins);

        $this->determineFormat();
        $this->verifyFormatCompatiblity();

        switch ($this->format) {
            case 'GIF':
                $this->oldImage = imagecreatefromgif($this->fileName);
                break;
            case 'JPG':
                $this->oldImage = imagecreatefromjpeg($this->fileName);
                break;
            case 'PNG':
                $this->oldImage = imagecreatefrompng($this->fileName);
                break;
            case 'STRING':
                $this->oldImage = imagecreatefromstring($this->fileName);
                break;
        }

        $this->currentDimensions = array (
            'width'  => imagesx($this->oldImage),
            'height' => imagesy($this->oldImage)
        );
    }
    
/**
     * Sets options for all operations.
     * @param array $options
     * @return GD
     */
    public function setOptions(array $options = array())
    {
        // we've yet to init the default options, so create them here
        if (sizeof($this->options) == 0) {
            $defaultOptions = array(
                'resizeUp'              => false,
                'jpegQuality'           => 100,
                'correctPermissions'    => false,
                'preserveAlpha'         => true,
                'alphaMaskColor'        => array (255, 255, 255),
                'preserveTransparency'  => true,
                'transparencyMaskColor' => array (0, 0, 0),
                'interlace'             => null
            );
        } else { // otherwise, let's use what we've got already
            $defaultOptions = $this->options;
        }

        $this->options = array_merge($defaultOptions, $options);

        return $this;
    }
Аватара пользователя
maleks
Сообщения: 1992
Зарегистрирован: 2012.12.26, 12:56

Re: ImageUploadBehavior и GD sizeof(null)

Сообщение maleks »

А что это за поведение?
nulled
Сообщения: 74
Зарегистрирован: 2018.10.30, 13:42

Re: ImageUploadBehavior и GD sizeof(null)

Сообщение nulled »

maleks писал(а): 2019.11.23, 07:47 А что это за поведение?
http://yiidreamteam.com/yii2/upload-behavior
Ответить