diff --git a/apps/files/index.php b/apps/files/index.php
index c05c2a9384dbd45341a2edb09488ac428733c3c4..3007f56e024ec0400dcb6682adb087a60310286d 100644
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -74,6 +74,7 @@ foreach ($content as $i) {
 		}
 	}
 	$i['directory'] = $dir;
+	$i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($i['mimetype']);
 	$files[] = $i;
 }
 
diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php
index 899fb04e2526024b2fdbe48c3bc50d1ece8b14b2..c91dda4c77ed5b92f0c5ca3d91d450767907a762 100644
--- a/apps/files/templates/part.list.php
+++ b/apps/files/templates/part.list.php
@@ -26,7 +26,7 @@ $totalsize = 0; ?>
 		data-mime="<?php p($file['mimetype'])?>"
 		data-size="<?php p($file['size']);?>"
 		data-permissions="<?php p($file['permissions']); ?>">
-		<?php if(\OCP\Preview::isMimeSupported($file['mimetype'])): ?>
+		<?php if($file['isPreviewAvailable']): ?>
 		<td class="filename svg preview-icon"
 		<?php else: ?>
 		<td class="filename svg"
@@ -38,13 +38,13 @@ $totalsize = 0; ?>
 				<?php
 				$relativePath = substr($relativePath, strlen($_['sharingroot']));
 				?>
-				<?php if(\OCP\Preview::isMimeSupported($file['mimetype'])): ?>
+				<?php if($file['isPreviewAvailable']): ?>
 				style="background-image:url(<?php print_unescaped(OCP\publicPreview_icon($relativePath, $_['sharingtoken'])); ?>)"
 				<?php else: ?>
 				style="background-image:url(<?php print_unescaped(OCP\mimetype_icon($file['mimetype'])); ?>)"
 				<?php endif; ?>
 			<?php else: ?>
-				<?php if(\OCP\Preview::isMimeSupported($file['mimetype'])): ?>	
+				<?php if($file['isPreviewAvailable']): ?>
 				style="background-image:url(<?php print_unescaped(OCP\preview_icon($relativePath)); ?>)"
 				<?php else: ?>
 				style="background-image:url(<?php print_unescaped(OCP\mimetype_icon($file['mimetype'])); ?>)"
diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php
index f050fecd7b5c9906c90d07a56bc228a64e58fb97..ec6b4e815f80ba5fc9c42728bfa0cf81d5eaf02e 100644
--- a/apps/files_sharing/public.php
+++ b/apps/files_sharing/public.php
@@ -172,6 +172,7 @@ if (isset($path)) {
 					} else {
 						$i['extension'] = '';
 					}
+					$i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($i['mimetype']);
 				}
 				$i['directory'] = $getPath;
 				$i['permissions'] = OCP\PERMISSION_READ;
diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php
index 2dbaefe7a78ebdca37331f3619f0a7db4e3b2bb1..6ae238eb8eb7a27f4f60665b9091180c1084f41f 100644
--- a/apps/files_trashbin/index.php
+++ b/apps/files_trashbin/index.php
@@ -64,6 +64,7 @@ foreach ($result as $r) {
 		$i['directory'] = '';
 	}
 	$i['permissions'] = OCP\PERMISSION_READ;
+	$i['isPreviewAvailable'] = \OCP\Preview::isMimeSupported($r['mime']);
 	$files[] = $i;
 }
 
diff --git a/apps/files_trashbin/templates/part.list.php b/apps/files_trashbin/templates/part.list.php
index 6c6d2162846633877641df91247bf7174695955f..f7cc6b01bbb5eb9eb381e8ce81d5b2128651e64c 100644
--- a/apps/files_trashbin/templates/part.list.php
+++ b/apps/files_trashbin/templates/part.list.php
@@ -21,12 +21,16 @@
 		data-timestamp='<?php p($file['timestamp']);?>'
 		data-dirlisting=0
 		<?php endif; ?>>
+		<?php if($file['isPreviewAvailable']): ?>
+		<td class="filename svg preview-icon"
+		<?php else: ?>
 		<td class="filename svg"
+		<?php endif; ?>
 		<?php if($file['type'] === 'dir'): ?>
 			style="background-image:url(<?php print_unescaped(OCP\mimetype_icon('dir')); ?>)"
 		<?php else: ?>
-				<?php if(\OCP\Preview::isMimeSupported($file['mimetype'])): ?>
-				style="background-image:url(<?php print_unescaped(OCA\Files_Trashbin\Trashbin::preview_icon(!$_['dirlisting'] ? ($file['name'].'.d'.$file['timestamp']) : ($file['directory'].'/'.$file['name']))); ?>)" class="preview-icon"
+				<?php if($file['isPreviewAvailable']): ?>
+				style="background-image:url(<?php print_unescaped(OCA\Files_Trashbin\Trashbin::preview_icon(!$_['dirlisting'] ? ($file['name'].'.d'.$file['timestamp']) : ($file['directory'].'/'.$file['name']))); ?>)"
 				<?php else: ?>
 				style="background-image:url(<?php print_unescaped(OCP\mimetype_icon($file['mimetype'])); ?>)"
 				<?php endif; ?>