From f89a23b463884e1a9b89c84fdcb1c34afba62645 Mon Sep 17 00:00:00 2001
From: Georg Ehrke <georg@ownCloud.com>
Date: Wed, 12 Jun 2013 16:18:16 +0200
Subject: [PATCH] implement unknown preview backend

---
 lib/preview/unknown.php | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/lib/preview/unknown.php b/lib/preview/unknown.php
index 6b16142491..6e1dc06c1b 100644
--- a/lib/preview/unknown.php
+++ b/lib/preview/unknown.php
@@ -15,12 +15,24 @@ class Unknown extends Provider {
 	}
 
 	public function getThumbnail($path, $maxX, $maxY, $scalingup, $fileview) {
-		/*$mimetype = $fileview->getMimeType($path);
-		$info = $fileview->getFileInfo($path);
-		$name = array_key_exists('name', $info) ? $info['name'] : '';
-		$size = array_key_exists('size', $info) ? $info['size'] : 0; 
-		$isencrypted = array_key_exists('encrypted', $info) ? $info['encrypted'] : false;*/ // show little lock
-		return new \OC_Image();
+		$mimetype = $fileview->getMimeType($path);
+		if(substr_count($mimetype, '/')) {
+			list($type, $subtype) = explode('/', $mimetype);
+		}
+
+		$iconsroot = \OC::$SERVERROOT . '/core/img/filetypes/';
+
+		$icons = array($mimetype, $type, 'text');
+		foreach($icons as $icon) {
+			$icon = str_replace('/', '-', $icon);
+
+			$iconpath = $iconsroot . $icon . '.png';
+
+			if(file_exists($iconpath)) {
+				return new \OC_Image($iconpath);
+			}
+		}
+		return false;
 	}
 }
 
-- 
GitLab