diff --git a/behaviors/ImageBehave.php b/behaviors/ImageBehave.php index dcd5412..ee62b1c 100755 --- a/behaviors/ImageBehave.php +++ b/behaviors/ImageBehave.php @@ -91,9 +91,16 @@ public function attachImage($absolutePath, $isMain = false) unlink($newAbsolutePath); throw new \Exception(array_shift($ar)); } + $img = $this->owner->getImage(); //If main image not exists - if(!$this->owner->getImage() or $isMain){ + if( + is_object($img) && get_class($img)=='rico\yii2images\models\PlaceHolder' + or + $img == null + or + $isMain + ){ $this->setMainImage($image); }