Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions app/src/components/card/searchCardImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@ import Image from "next/image";
import React from "react";
import { useState } from "react";
import { Box } from "@nypl/design-system-react-components";
import SearchCardType from "@/src/types/SearchCardType";

export const SearchCardImage = ({ record, viewMode }) => {
type SearchCardImageProps = {
record: SearchCardType;
viewMode: "grid" | "list";
};

export const SearchCardImage = ({ record, viewMode }: SearchCardImageProps) => {
const fallbackImageSrc = {
Image: "/noImage.png",
Audio: "/noAudio.png",
Video: "/noVideo.png",
}[record.contentType ?? "Image"];
const [imageSrc, setImageSrc] = useState(
record.videoThumbnail || (record.imageID ? record.imageURL : "/noImage.png")
record.videoThumbnail ||
(record.imageID ? record.imageURL : fallbackImageSrc)
);

return (
Expand Down Expand Up @@ -45,7 +57,7 @@ export const SearchCardImage = ({ record, viewMode }) => {
console.warn(
`SearchCardImage: Card image failed to load, fallback image loaded instead. ImageURL: ${record.imageURL}`
);
setImageSrc("/noImage.png");
setImageSrc(fallbackImageSrc);
}}
/>
</Box>
Expand Down
1 change: 1 addition & 0 deletions app/src/types/SearchCardType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface SearchCardType {
url: string;
imageID: string;
imageURL: string;
videoThumbnail: string | null;
recordType: SearchResultRecordType;
numberOfDigitizedItems: number;
containsOnSiteMaterial: boolean;
Expand Down
Binary file added public/noAudio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/noImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/noVideo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading