Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UI error when image has no files #5325

Merged
Merged
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
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
Loading