diff --git a/Kwf/Media.php b/Kwf/Media.php
index <HASH>..<HASH> 100644
--- a/Kwf/Media.php
+++ b/Kwf/Media.php
@@ -225,6 +225,19 @@ class Kwf_Media
         return Kwf_Config::getValue('mediaCacheDir').'/'.$class.'/'.$groupingFolder.'/'.$id.'/'.$type;
     }
 
+    private static function _deleteFolder($path)
+    {
+        foreach (array_slice(scandir($path), 2) as $fileOrFolder) {
+            $fileOrFolderPath = $path.'/'.$fileOrFolder;
+            if (is_file($fileOrFolderPath)) {
+                unlink($fileOrFolderPath);
+            } else {
+                self::_deleteFolder($fileOrFolderPath);
+            }
+        }
+        rmdir($path);
+    }
+
     public static function collectGarbage($debug)
     {
         $cacheFolder = Kwf_Config::getValue('mediaCacheDir');
@@ -233,6 +246,11 @@ class Kwf_Media
         foreach ($mediaClasses as $mediaClass) {
             if (is_file($cacheFolder.'/'.$mediaClass)) continue;
 
+            if (!class_exists($mediaClass)) {
+                self::_deleteFolder($cacheFolder.'/'.$mediaClass);
+                continue;
+            }
+
             if (!is_instance_of($mediaClass, 'Kwf_Media_Output_ClearCacheInterface')) continue;
 
             $classFolder = $cacheFolder.'/'.$mediaClass;
Delete mediaCache-folders for removed components

This is also required as is_instance_of throws exception if class
is not existing.