From 70310678444a43c1ef3f460d9761ad0c2818f001 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 15 Jun 2025 17:09:08 +0400 Subject: feat: thumbnails for audio, text and other files --- public/index.php | 18 ++++++++++++++++-- public/static/img/icons/file.png | Bin 0 -> 635 bytes public/static/img/icons/file_audio.png | Bin 0 -> 385 bytes public/static/img/icons/file_text.png | Bin 0 -> 342 bytes 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100755 public/static/img/icons/file.png create mode 100755 public/static/img/icons/file_audio.png create mode 100755 public/static/img/icons/file_text.png (limited to 'public') diff --git a/public/index.php b/public/index.php index 4186399..9a0e293 100644 --- a/public/index.php +++ b/public/index.php @@ -539,6 +539,20 @@ $privacy_exists = is_file($_SERVER['DOCUMENT_ROOT'] . '/static/PRIVACY.txt'); file_deletion = ``; } + + let thumbnailPath = `/${file.id}.webp`; + let thumbnailSize = "width: 64px; height: 64px;"; + if (file.mime.startsWith('audio/')) { + thumbnailPath = '/static/img/icons/file_audio.png'; + } else if (file.mime.startsWith('text/')) { + thumbnailPath = '/static/img/icons/file_text.png'; + } else if (!file.mime.startsWith('image/') && !file.mime.startsWith('video/')) { + thumbnailPath = '/static/img/icons/file.png'; + } else { + thumbnailSize = 'max-width:100%; max-height: 100%;'; + } + + return `
-
-

No thumbnail.

+
+

No thumbnail.

diff --git a/public/static/img/icons/file.png b/public/static/img/icons/file.png new file mode 100755 index 0000000..03ddd79 Binary files /dev/null and b/public/static/img/icons/file.png differ diff --git a/public/static/img/icons/file_audio.png b/public/static/img/icons/file_audio.png new file mode 100755 index 0000000..a8b3ede Binary files /dev/null and b/public/static/img/icons/file_audio.png differ diff --git a/public/static/img/icons/file_text.png b/public/static/img/icons/file_text.png new file mode 100755 index 0000000..813f712 Binary files /dev/null and b/public/static/img/icons/file_text.png differ -- cgit v1.2.3