add thumbnail generation

This commit is contained in:
2026-03-25 16:59:09 -04:00
parent 90528c4768
commit bf54b45fa1
9 changed files with 317 additions and 39 deletions

View File

@@ -18,6 +18,10 @@ function fileApiUrl(libraryId: string, relativePath: string): string {
return `/api/file?libraryId=${encodeURIComponent(libraryId)}&path=${encodeURIComponent(relativePath)}`
}
function thumbnailApiUrl(libraryId: string, relativePath: string): string {
return `/api/thumbnail?libraryId=${encodeURIComponent(libraryId)}&path=${encodeURIComponent(relativePath)}`
}
export function scanDirectory(
libraryRoot: string,
libraryId: string,
@@ -43,17 +47,20 @@ export function scanDirectory(
type: 'directory',
mediaType: null,
url: null,
thumbnailUrl: null,
}
}
const relPath = subpath ? path.join(subpath, d.name) : d.name
const mediaType = getMediaType(d.name)
const hasThumbnail = mediaType === 'image' || mediaType === 'video'
return {
name: d.name,
type: 'file',
mediaType,
url: fileApiUrl(libraryId, relPath),
thumbnailUrl: hasThumbnail ? thumbnailApiUrl(libraryId, relPath) : null,
}
})