diff --git a/app/src/components/Files.js b/app/src/components/Files.js index 4e0cf8e0..2dfa04e0 100644 --- a/app/src/components/Files.js +++ b/app/src/components/Files.js @@ -41,7 +41,7 @@ import {FileBrowser} from "./FileBrowser"; import {refreshDirectoryFiles, refreshFiles} from "../api"; import {useSubscribeEventName} from "../Events"; import {FilePreviewContext} from "./FilePreview"; -import {TagsContext} from "../Tags"; +import {taggedImageLabel, TagsContext} from "../Tags"; export function FilesPage() { @@ -121,6 +121,18 @@ function ImageCard({file}) { } +function findPosterPath(files) { + if (_.isEmpty(files)) { + return; + } + for (let i = 0; i < files.length; i++) { + const file = files[i]; + if (file['mimetype'] && file['mimetype'].startsWith('image/')) { + return file['path']; + } + } +} + function FileCard({file}) { const {s} = useContext(ThemeContext); @@ -138,7 +150,7 @@ function FileCard({file}) { return ; } - const {data} = file; + const {data, tags} = file; let author; if (data) { author = data['author']; @@ -147,11 +159,17 @@ function FileCard({file}) { const color = mimetypeColor(file.mimetype); const size = file.size !== null && file.size !== undefined ? humanFileSize(file.size) : null; + const posterFile = findPosterPath(file['files']); + let poster = ; + let imageLabel = !_.isEmpty(tags) ? taggedImageLabel : null; + if (posterFile) { + const posterUrl = `/media/${encodeURIComponent(posterFile)}`; + poster = ; + } + return - - - + {poster}