This commit is contained in:
Devon22 2025-05-07 00:46:42 +08:00
parent dbb3160fa0
commit 27a5f08b35
6 changed files with 14 additions and 5 deletions

View file

@ -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",

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "mediaviewer",
"version": "1.9.5",
"version": "1.9.6",
"lockfileVersion": 3,
"requires": true,
"packages": {

View file

@ -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": {

View file

@ -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 已經存在,將新的連結文字加入到現有的列表中

View file

@ -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),

View file

@ -1,3 +1,3 @@
{
"1.9.5": "1.1.0"
"1.9.6": "1.1.0"
}