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
2 changes: 1 addition & 1 deletion packages/contentful/src/lib/aspectRatio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const orientationMediaQueries = [
export function getImageAspect(
image: ContentfulImageAsset | undefined | null,
): number | undefined {
if (!image) return undefined;
if (!image || image.width == null || image.height == null) return undefined;
return image.width / image.height;
}

Expand Down
12 changes: 6 additions & 6 deletions packages/contentful/src/types/contentfulVisualTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ export type ContentfulVisualProps = {
image?: ContentfulImageAsset | null;
video?: ContentfulAsset | null;
src?: ContentfulVisualEntry | null;
alt?: string; // Can be inferrerd
alt?: string | null; // Can be inferrerd
} & Omit<ReactVisualProps, "alt" | "image" | "video">;

export type ContentfulImageAsset = ContentfulAsset & {
width: number;
height: number;
width?: number | null;
height?: number | null;
};

export type ContentfulAsset = {
title?: string | null;
description?: string; // Was not nullable in my tests
description?: string | null;
fileName?: string;
url: string;
url?: string | null;
};

export type ContentfulVisualEntry = {
image?: ContentfulImageAsset | null;
portraitImage?: ContentfulImageAsset | null;
video?: ContentfulAsset | null;
portraitVideo?: ContentfulAsset | null;
alt: string | null;
alt?: string | null;
};