From 20e69bc1b00bcc6cdf88de6f59b97856678202e9 Mon Sep 17 00:00:00 2001
From: "John Molakvoæ (skjnldsv)" <skjnldsv@protonmail.com>
Date: Thu, 15 May 2025 12:23:39 +0200
Subject: feat(files): show readable mime if available
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
---
 apps/files/src/components/FileEntry.vue | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

(limited to 'apps/files/src/components/FileEntry.vue')

diff --git a/apps/files/src/components/FileEntry.vue b/apps/files/src/components/FileEntry.vue
index 3e455a2f135..d66c3fa0ed7 100644
--- a/apps/files/src/components/FileEntry.vue
+++ b/apps/files/src/components/FileEntry.vue
@@ -97,6 +97,7 @@
 import { FileType, formatFileSize } from '@nextcloud/files'
 import { useHotKey } from '@nextcloud/vue/composables/useHotKey'
 import { defineComponent } from 'vue'
+import { t } from '@nextcloud/l10n'
 import NcDateTime from '@nextcloud/vue/components/NcDateTime'
 
 import { useNavigation } from '../composables/useNavigation.ts'
@@ -208,6 +209,25 @@ export default defineComponent({
 				return t('files', 'Unknown file type')
 			}
 
+			if (window.OC?.MimeTypeList?.names?.[this.source.mime]) {
+				return window.OC.MimeTypeList.names[this.source.mime]
+			}
+
+			const baseType = this.source.mime.split('/')[0]
+			const ext = this.source?.extension?.toUpperCase().replace(/^\./, '') || ''
+			if (baseType === 'image') {
+				return t('files', '{ext} image', { ext })
+			}
+			if (baseType === 'video') {
+				return t('files', '{ext} video', { ext })
+			}
+			if (baseType === 'audio') {
+				return t('files', '{ext} audio', { ext })
+			}
+			if (baseType === 'text') {
+				return t('files', '{ext} text', { ext })
+			}
+
 			return this.source.mime
 		},
 		size() {
-- 
cgit v1.2.3

