/** * Remove an image from the storage system. * * @param integer $imageId * @param boolean $cleanup If cleanup is enabled, all other images will be deleted, the source file will be deleted to * if clean is disabled, only the provided $imageId will be removed. * @since 1.0.0-beta3 */ public static function removeImage($imageId, $cleanup = true) { if (!$cleanup) { Yii::$app->storage->flushArrays(); return StorageImage::findOne($imageId)->delete(); } $image = Yii::$app->storage->getImage($imageId); if ($image) { $fileId = $image->fileId; foreach (Yii::$app->storage->findImages(['file_id' => $fileId]) as $imageItem) { StorageImage::findOne($imageItem->id)->delete(); } Yii::$app->storage->flushArrays(); return static::removeFile($fileId); } return false; }