yii2-crop-image-upload
yii2-crop-image-upload copied to clipboard
Error if no image selected
I must modify afterSave function in CropImageUploadBehavior
public function afterSave()
{
parent::afterSave();
if (in_array($this->owner->scenario, $this->scenarios)) {
$image = null;
foreach ($this->getConfigurations() as $crop) {
if ($crop['_changed']) {
if (!$image) {
$path = $this->getUploadPath($this->attribute);
if (!$path) {
$path = $this->getUploadPath($this->attribute, true);
}
}
if ($path) {
$image = Image::getImagine()->open($path);
$this->createCrop($crop, $image->copy());
}
}
}
}
}
could you send me error details? this change doesn't looks good for me
Try to created a form with CropImageUpload field inside. Create a new record but don't upload any image... just leave it blank and save
This is the error message: Imagine\Exception\InvalidArgumentException File doesn't exist
in this case $crop['_changed'] shouldn't be true will check
@karpoff
Have you fixed this issue?
I have changed CropImageUploadBehavior
protected function createCrop() { $path = $this->getUploadPath($this->attribute); if($path) $image = Image::getImagine()->open($path); else return true;
I know it is not correct way, but I'm waiting for solution :100: