diff --git a/apps/theming/lib/ImageManager.php b/apps/theming/lib/ImageManager.php index 309bf192bc3f0..8ba558d7947a8 100644 --- a/apps/theming/lib/ImageManager.php +++ b/apps/theming/lib/ImageManager.php @@ -202,8 +202,6 @@ public function delete(string $key): void { } public function updateImage(string $key, string $tmpFile): string { - $this->delete($key); - try { $folder = $this->getRootFolder()->getFolder('images'); } catch (NotFoundException $e) { @@ -217,6 +215,8 @@ public function updateImage(string $key, string $tmpFile): string { throw new \Exception('Unsupported image type: ' . $detectedMimeType); } + $this->delete($key); + if ($key === 'background') { if ($this->shouldOptimizeBackgroundImage($detectedMimeType, filesize($tmpFile))) { try {