@@ -7,30 +7,42 @@ const DEFAULT_IMAGE_BREAKPOINTS = [16, 32, 48, 64, 96, 128, 256, 384] as const
7
7
8
8
export interface GetImageAttributesOptions extends SrcOptions {
9
9
/**
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
+ */
14
17
width ?: number
15
18
16
19
/**
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`.
20
27
*/
21
28
sizes ?: string
22
29
23
30
/**
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.
27
36
*/
28
37
deviceBreakpoints ?: number [ ]
29
38
30
39
/**
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`.
33
44
* Defaults to `[16, 32, 48, 64, 96, 128, 256, 384]`.
45
+ * Sorted automatically.
34
46
*/
35
47
imageBreakpoints ?: number [ ]
36
48
}
@@ -40,9 +52,13 @@ export interface GetImageAttributesOptions extends SrcOptions {
40
52
* Useful for enabling responsive image loading.
41
53
*/
42
54
export interface ResponsiveImageAttributes {
55
+ /** URL for the *largest* candidate (assigned to plain `src`). */
43
56
src : string
57
+ /** Candidate set with `w` or `x` descriptors. */
44
58
srcSet ?: string
59
+ /** `sizes` returned (or synthesised as `100vw`). */
45
60
sizes ?: string
61
+ /** Width as a number (if `width` was provided). */
46
62
width ?: number
47
63
}
48
64
0 commit comments