@@ -7,30 +7,42 @@ const DEFAULT_IMAGE_BREAKPOINTS = [16, 32, 48, 64, 96, 128, 256, 384] as const
77
88export interface GetImageAttributesOptions extends SrcOptions {
99 /**
10- * The intended display width (in pixels) of the image on screen.
11- * Used for calculating `srcSet` with a pixel-density (DPR) strategy.
12- * If omitted, a width-based strategy using breakpoints will be applied.
13- */
10+ * The intended display width of the image in pixels,
11+ * used **only when the `sizes` attribute is not provided**.
12+ *
13+ * Triggers a DPR-based strategy (1x and 2x variants) and generates `x` descriptors in `srcSet`.
14+ *
15+ * Ignored if `sizes` is present.
16+ */
1417 width ?: number
1518
1619 /**
17- * The `sizes` attribute for the image element.
18- * Typically used to indicate how the image will scale across different viewport sizes (e.g., "100vw").
19- * Presence of `sizes` triggers a width-based `srcSet` strategy.
20+ * The value for the HTML `sizes` attribute
21+ * (e.g., `"100vw"` or `"(min-width:768px) 50vw, 100vw"`).
22+ *
23+ * - If it includes one or more `vw` units, breakpoints smaller than the corresponding percentage of the smallest device width are excluded.
24+ * - If it contains no `vw` units, the full breakpoint list is used.
25+ *
26+ * Enables a width-based strategy and generates `w` descriptors in `srcSet`.
2027 */
2128 sizes ?: string
2229
2330 /**
24- * An optional custom list of device width breakpoints (in pixels).
25- * If not specified, defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`.
26- * Recommended to align with your target audience's common screen widths.
31+ * Custom list of **device-width breakpoints** in pixels.
32+ * These define common screen widths for responsive image generation.
33+ *
34+ * Defaults to `[640, 750, 828, 1080, 1200, 1920, 2048, 3840]`.
35+ * Sorted automatically.
2736 */
2837 deviceBreakpoints ?: number [ ]
2938
3039 /**
31- * An optional list of custom image breakpoints (in pixels).
32- * These are merged with the device breakpoints to compute the final list of candidate widths.
40+ * Custom list of **image-specific breakpoints** in pixels.
41+ * Useful for generating small variants (e.g., placeholders or thumbnails).
42+ *
43+ * Merged with `deviceBreakpoints` before calculating `srcSet`.
3344 * Defaults to `[16, 32, 48, 64, 96, 128, 256, 384]`.
45+ * Sorted automatically.
3446 */
3547 imageBreakpoints ?: number [ ]
3648}
@@ -40,9 +52,13 @@ export interface GetImageAttributesOptions extends SrcOptions {
4052 * Useful for enabling responsive image loading.
4153 */
4254export interface ResponsiveImageAttributes {
55+ /** URL for the *largest* candidate (assigned to plain `src`). */
4356 src : string
57+ /** Candidate set with `w` or `x` descriptors. */
4458 srcSet ?: string
59+ /** `sizes` returned (or synthesised as `100vw`). */
4560 sizes ?: string
61+ /** Width as a number (if `width` was provided). */
4662 width ?: number
4763}
4864
0 commit comments