Skip to content

Commit

Permalink
Fix UI error when image has no files (#5325)
Browse files Browse the repository at this point in the history
  • Loading branch information
WithoutPants authored Oct 1, 2024
1 parent 93a2ee1 commit 76a5b2a
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions ui/v2.5/src/components/Images/ImageDetails/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
);

const title = objectTitle(image);
const ImageView = isVideo(image.visual_files[0]) ? "video" : "img";
const ImageView =
image.visual_files.length > 0 && isVideo(image.visual_files[0])
? "video"
: "img";

const resolution = useMemo(() => {
return file?.width && file?.height
Expand Down Expand Up @@ -362,19 +365,21 @@ const ImagePage: React.FC<IProps> = ({ image }) => {
{renderTabs()}
</div>
<div className="image-container">
<ImageView
loop={image.visual_files[0].__typename == "VideoFile"}
autoPlay={image.visual_files[0].__typename == "VideoFile"}
controls={image.visual_files[0].__typename == "VideoFile"}
className="m-sm-auto no-gutter image-image"
style={
image.visual_files[0].__typename == "VideoFile"
? { width: "100%", height: "100%" }
: {}
}
alt={title}
src={image.paths.image ?? ""}
/>
{image.visual_files.length > 0 && (
<ImageView
loop={image.visual_files[0].__typename == "VideoFile"}
autoPlay={image.visual_files[0].__typename == "VideoFile"}
controls={image.visual_files[0].__typename == "VideoFile"}
className="m-sm-auto no-gutter image-image"
style={
image.visual_files[0].__typename == "VideoFile"
? { width: "100%", height: "100%" }
: {}
}
alt={title}
src={image.paths.image ?? ""}
/>
)}
</div>
</div>
);
Expand Down

0 comments on commit 76a5b2a

Please sign in to comment.