public function deleteImage($updateDb = false)
    {
        $owner = $this->owner;
        $DS = DIRECTORY_SEPARATOR;

        $image = str_replace('/', $DS, $this->_oldImage);

        if (!empty($image)) {
            $dirName = Yii::getAlias($this->_savePathAlias);
            // Remove all resized images
            foreach ($this->getImageSizes() as $prefix => $size) {
                $file_name = $dirName . $DS . static::addPrefixToFile($image, $prefix);
                @unlink($file_name);
            }
            // Remove original image
            @unlink($this->getOriginalImagePath());
        }

        // Clear field value
        $owner->{$this->_imageAttribute} = null;
        $this->_oldImage = null;

        if ($updateDb) {
            $owner->update(false, [$this->_imageAttribute]);
        }
    }
public function deleteImage($updateDb = false)
    {
        $owner = $this->owner;
        $DS = DIRECTORY_SEPARATOR;

        $image = str_replace('/', $DS, $this->_oldImage);

        if (!empty($image)) {
            $dirName = Yii::getAlias($this->_savePathAlias);
            // Remove all resized images
            foreach ($this->getImageSizes() as $prefix => $size) {
                $file_name = $dirName . $DS . static::addPrefixToFile($image, $prefix);
                @unlink($file_name);
            }
            // Remove original image
            @unlink($this->getOriginalImagePath());
        }

        // Clear field value
        $owner->{$this->_imageAttribute} = null;
        $this->_oldImage = null;

        if ($updateDb) {
            $owner->update(false, [$this->_imageAttribute]);
        }
    }
public function deleteImage ( $ updateDb = false ) { $ owner = $ this -> owner ; $ DS = DIRECTORY_SEPARATOR ; $ image = str_replace ( '/' , $ DS , $ this -> _oldImage ) ; if ( ! empty ( $ image ) ) { $ dirName = Yii :: getAlias ( $ this -> _savePathAlias ) ; // Remove all resized images foreach ( $ this -> getImageSizes ( ) as $ prefix => $ size ) { $ file_name = $ dirName . $ DS . static :: addPrefixToFile ( $ image , $ prefix ) ; @ unlink ( $ file_name ) ; } // Remove original image @ unlink ( $ this -> getOriginalImagePath ( ) ) ; } // Clear field value $ owner -> { $ this -> _imageAttribute } = null ; $ this -> _oldImage = null ; if ( $ updateDb ) { $ owner -> update ( false , [ $ this -> _imageAttribute ] ) ; } }
Delete image file and set|save model image field to null

@param bool $updateDb need to update image field in DB
Delete image file and set|save model image field to null