Fix: Image files displaying as normal files
This commit is contained in:
parent
bf61c339e1
commit
44fbc4ebdc
2 changed files with 6 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ import DownloadButton from "./components/downloadButton/downloadButton";
|
||||||
import getClasses from "./utils/get-classes";
|
import getClasses from "./utils/get-classes";
|
||||||
import handleDownload from "./utils/handle-download";
|
import handleDownload from "./utils/handle-download";
|
||||||
|
|
||||||
const imgTypes = new Set(["png", "jpg"]);
|
const imgTypes = new Set(["png", "jpg", "jpeg", "gif", "webp", "image"]);
|
||||||
|
|
||||||
export default function FileCard({
|
export default function FileCard({
|
||||||
fileName,
|
fileName,
|
||||||
|
|
@ -29,7 +29,7 @@ export default function FileCard({
|
||||||
|
|
||||||
const imgSrc = `${BACKEND_URL.slice(
|
const imgSrc = `${BACKEND_URL.slice(
|
||||||
0,
|
0,
|
||||||
BACKEND_URL.length - 1
|
BACKEND_URL.length - 1,
|
||||||
)}${BASE_URL_API}files/images/${content}`;
|
)}${BASE_URL_API}files/images/${content}`;
|
||||||
|
|
||||||
if (showFile) {
|
if (showFile) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import IconComponent, {
|
||||||
import { Skeleton } from "../../../../../components/ui/skeleton";
|
import { Skeleton } from "../../../../../components/ui/skeleton";
|
||||||
import formatFileName from "./utils/format-file-name";
|
import formatFileName from "./utils/format-file-name";
|
||||||
|
|
||||||
|
const supImgFiles = ["png", "jpg", "jpeg", "gif", "bmp", "webp", "image"];
|
||||||
|
|
||||||
export default function FilePreview({
|
export default function FilePreview({
|
||||||
error,
|
error,
|
||||||
file,
|
file,
|
||||||
|
|
@ -16,7 +18,8 @@ export default function FilePreview({
|
||||||
error: boolean;
|
error: boolean;
|
||||||
onDelete: () => void;
|
onDelete: () => void;
|
||||||
}) {
|
}) {
|
||||||
const isImage = file.type.toLowerCase().includes("image");
|
const fileType = file.type.toLowerCase();
|
||||||
|
const isImage = supImgFiles.some((type) => fileType.includes(type));
|
||||||
|
|
||||||
const [isHovered, setIsHovered] = useState(false);
|
const [isHovered, setIsHovered] = useState(false);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue