summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alper Doğan <48688801+doganalper@users.noreply.github.com> 2023-04-10 15:09:02 +0300
committerGravatar GitHub <noreply@github.com> 2023-04-10 14:09:02 +0200
commit99479e6b9505dc929997b5c42f4d7b30d54ef074 (patch)
tree26044bff0eac0c4ad2427297b04c6040d2686f0a
parenta5601a3cd35b6d346ea8843a2a33a3238079cdba (diff)
downloadastro-99479e6b9505dc929997b5c42f4d7b30d54ef074.tar.gz
astro-99479e6b9505dc929997b5c42f4d7b30d54ef074.tar.zst
astro-99479e6b9505dc929997b5c42f4d7b30d54ef074.zip
Optional `Sizes` prop on Picture component (#6773)
-rw-r--r--.changeset/breezy-roses-smash.md5
-rw-r--r--packages/integrations/image/components/Picture.astro3
-rw-r--r--packages/integrations/image/components/index.ts4
3 files changed, 9 insertions, 3 deletions
diff --git a/.changeset/breezy-roses-smash.md b/.changeset/breezy-roses-smash.md
new file mode 100644
index 000000000..59ec9a17d
--- /dev/null
+++ b/.changeset/breezy-roses-smash.md
@@ -0,0 +1,5 @@
+---
+'@astrojs/image': patch
+---
+
+Make sizes prop optional on Image component
diff --git a/packages/integrations/image/components/Picture.astro b/packages/integrations/image/components/Picture.astro
index f8958f8fe..bdaaceae0 100644
--- a/packages/integrations/image/components/Picture.astro
+++ b/packages/integrations/image/components/Picture.astro
@@ -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;
@@ -24,7 +25,7 @@ if (alt === undefined || alt === null) {
warnForMissingAlt();
}
-const { image, sources } = await getPicture({
+const { image, sources }: GetPictureResult = await getPicture({
src,
widths,
formats,
diff --git a/packages/integrations/image/components/index.ts b/packages/integrations/image/components/index.ts
index 2ca557656..3135e0e21 100644
--- a/packages/integrations/image/components/index.ts
+++ b/packages/integrations/image/components/index.ts
@@ -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[];
}
@@ -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'];
}