src/helpers/Storage.php
public static function removeImage($imageId, $cleanup = false)
    {
        Yii::$app->storage->flushArrays();
        $image = Yii::$app->storage->getImage($imageId);
        if ($cleanup && $image) {
            $fileId = $image->fileId;
            foreach (Yii::$app->storage->findImages(['file_id' => $fileId]) as $imageItem) {
                $storageImage = StorageImage::findOne($imageItem->id);
                if ($storageImage) {
                    $storageImage->delete();
                }
            }
        }
        
        $file = StorageImage::findOne($imageId);
        if ($file) {
            return $file->delete();
        }
        
        return false;
    }
public static function removeImage($imageId, $cleanup = false)
    {
        Yii::$app->storage->flushArrays();
        $image = Yii::$app->storage->getImage($imageId);
        if ($cleanup && $image) {
            $fileId = $image->fileId;
            foreach (Yii::$app->storage->findImages(['file_id' => $fileId]) as $imageItem) {
                $storageImage = StorageImage::findOne($imageItem->id);
                if ($storageImage) {
                    $storageImage->delete();
                }
            }
        }
        
        $file = StorageImage::findOne($imageId);
        if ($file) {
            return $file->delete();
        }
        
        return false;
    }
public static function removeImage ( $ imageId , $ cleanup = false ) { Yii :: $ app -> storage -> flushArrays ( ) ; $ image = Yii :: $ app -> storage -> getImage ( $ imageId ) ; if ( $ cleanup && $ image ) { $ fileId = $ image -> fileId ; foreach ( Yii :: $ app -> storage -> findImages ( [ 'file_id' => $ fileId ] ) as $ imageItem ) { $ storageImage = StorageImage :: findOne ( $ imageItem -> id ) ; if ( $ storageImage ) { $ storageImage -> delete ( ) ; } } } $ file = StorageImage :: findOne ( $ imageId ) ; if ( $ file ) { return $ file -> delete ( ) ; } return false ; }
Remove an image from the storage system and database.

@param integer $imageId The corresponding imageId for the {{\luya\admin\models\StorageImage}} Model to remove.
@param boolean $cleanup If cleanup is enabled, all other images will be deleted. Even the {{\luya\admin\models\StorageFile}} will be removed
from the database and filesystem. By default cleanup is disabled and will only remove the provided $imageId itself from {{\luya\admin\models\StorageImage}}.
@return boolean
Remove an image from the storage system and database .