public static function writeHook($params) { self::removeHook($params); //only create 5 thumbnails max in one request to prevent locking up the request if (self::$writeHookCount < 5) { $path = $params['path']; $mime = \OC\Files\Filesystem::getMimetype($path); if (substr($mime, 0, 6) === 'image/') { self::$writeHookCount++; new Thumbnail($path); } } }