Skip to content

Commit

Permalink
Optional Sizes prop on Picture component (#6773)
Browse files Browse the repository at this point in the history
  • Loading branch information
doganalper authored Apr 10, 2023
1 parent a5601a3 commit 99479e6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-roses-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@astrojs/image': patch
---

Make sizes prop optional on Image component
3 changes: 2 additions & 1 deletion packages/integrations/image/components/Picture.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { getPicture } from '../dist/index.js';
import { warnForMissingAlt } from './index.js';
import type { PictureComponentLocalImageProps, PictureComponentRemoteImageProps } from './index.js';
import type { GetPictureResult } from '../src/lib/get-picture.js';
export type Props = PictureComponentLocalImageProps | PictureComponentRemoteImageProps;
Expand All @@ -24,7 +25,7 @@ if (alt === undefined || alt === null) {
warnForMissingAlt();
}
const { image, sources } = await getPicture({
const { image, sources }: GetPictureResult = await getPicture({
src,
widths,
formats,
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/image/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export interface PictureComponentLocalImageProps
src: ImageMetadata | Promise<{ default: ImageMetadata }>;
/** Defines an alternative text description of the image. Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel). */
alt: string;
sizes: HTMLImageElement['sizes'];
widths: number[];
sizes?: HTMLImageElement['sizes'];
formats?: OutputFormat[];
}

Expand All @@ -43,9 +43,9 @@ export interface PictureComponentRemoteImageProps
src: string;
/** Defines an alternative text description of the image. Set to an empty string (alt="") if the image is not a key part of the content (it's decoration or a tracking pixel). */
alt: string;
sizes: HTMLImageElement['sizes'];
widths: number[];
aspectRatio: TransformOptions['aspectRatio'];
sizes?: HTMLImageElement['sizes'];
formats?: OutputFormat[];
background?: TransformOptions['background'];
}
Expand Down

0 comments on commit 99479e6

Please sign in to comment.