public/Remove-RecipeImage.ps1

function Remove-RecipeImage {
    [CmdletBinding()]
    param(
        [Parameter(Mandatory)]
        [int]$RecipeId
    )

    $row = Invoke-RecipeDbQuery -Query "SELECT ImageFileName FROM Recipes WHERE RecipeId = $RecipeId;"

    if ($row -and $row.ImageFileName) {
        $fileName = $row.ImageFileName
        $path = Join-Path (Get-RecipeImageFolder) $fileName

        if (Test-Path $path) {
            Remove-Item -Path $path -Force -ErrorAction SilentlyContinue
        }
    }

    Invoke-RecipeDbQuery -Query @"
UPDATE Recipes
SET ImageFileName = NULL,
    ImageUpdatedAt = NULL,
    UpdatedAt = datetime('now')
WHERE RecipeId = $RecipeId;
"@
 | Out-Null
}