diff --git a/manifest.json b/manifest.json index 5dfda22..40f8db0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "mediaviewer", "name": "Media Viewer", - "version": "1.9.5", + "version": "1.9.6", "minAppVersion": "1.1.0", "description": "View and manage media files within your notes.", "author": "Devon22", diff --git a/package-lock.json b/package-lock.json index 71f1843..1418144 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mediaviewer", - "version": "1.9.5", + "version": "1.9.6", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index 5b695c7..6ddb03f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mediaviewer", - "version": "1.9.5", + "version": "1.9.6", "description": "This is a sample plugin for Obsidian (https://obsidian.md)", "main": "main.js", "scripts": { diff --git a/src/fullscreen.ts b/src/fullscreen.ts index 2f8e392..b747b49 100644 --- a/src/fullscreen.ts +++ b/src/fullscreen.ts @@ -110,12 +110,21 @@ export class FullScreenModal extends Modal { if (url) { let type = 'image'; + const urlExtension = url.split('.').pop()?.toLowerCase(); // Get extension from URL + if (file) { const extension = file.extension.toLowerCase(); if (!extension.match(/^(jpg|jpeg|png|gif|webp|mp4|mkv|mov|webm|flac|m4a|mp3|ogg|wav|3gp)$/)) { continue; } type = extension.match(/^(jpg|jpeg|png|gif|webp)$/) ? 'image' : 'video'; + } else if (urlExtension) { // If it's an external URL, check its extension + if (urlExtension.match(/^(mp4|mkv|mov|webm|flac|m4a|mp3|ogg|wav|3gp)$/)) { + type = 'video'; + } else if (!urlExtension.match(/^(jpg|jpeg|png|gif|webp)$/)) { + // If the extension is not a known video or image type, skip it + continue; + } } // 如果這個 URL 已經存在,將新的連結文字加入到現有的列表中 diff --git a/src/galleryBlock.ts b/src/galleryBlock.ts index f65dd2e..da6bf51 100644 --- a/src/galleryBlock.ts +++ b/src/galleryBlock.ts @@ -312,7 +312,7 @@ export class GalleryBlock { // 如果找不到檔案,再嘗試直接用路徑查找 const fileByPath = this.app.vault.getAbstractFileByPath(url); if (fileByPath && fileByPath instanceof TFile) { - const extension = url.toLowerCase(); + const extension = fileByPath.extension.toLowerCase(); items.push({ type: extension.match(/\.(mp4|mkv|mov|webm|mp3|m4a|flac|ogg|wav|3gp)$/) ? 'video' : 'image', url: this.app.vault.getResourcePath(fileByPath), diff --git a/versions.json b/versions.json index 3ede861..84e1471 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "1.9.5": "1.1.0" + "1.9.6": "1.1.0" } \ No newline at end of file