ImgProcProcessorOptions
Defined in: types.ts:248
Component options
- Part of props
Properties
Section titled “Properties”
optional
alt:string
Defined in: types.ts:257
artDirectives?
Section titled “artDirectives?”
optional
artDirectives:ImgProcArtDirectiveSourceProps
[]
Defined in: types.ts:433
Array of art directive objects
asBackground?
Section titled “asBackground?”
optional
asBackground:boolean
Defined in: types.ts:393
Enforce background mode
- Only for
<Image>
and<Picture>
components.
Default
Section titled “Default”false
backgroundPosition?
Section titled “backgroundPosition?”
optional
backgroundPosition:null
|string
Defined in: types.ts:380
Set CSS property background-position
to the container element or the blurred image
- For
<Background>
component, apply to the container element. - If
<Image>
or<Picture>
component and theplaceholder
isblurred
, apply to the<picture>
and<img>
elements.
MDN Reference: background-position
Default
Section titled “Default”"50% 50%"
backgroundSize?
Section titled “backgroundSize?”
optional
backgroundSize:null
|string
Defined in: types.ts:372
Set CSS property background-size
to the container element or the blurred image
- For
<Background>
component, apply to the container element. - If
<Image>
or<Picture>
component and theplaceholder
isblurred
, apply to the<picture>
and<img>
elements.
MDN Reference: background-size
Default
Section titled “Default”"cover"
blurProcessor
Section titled “blurProcessor”blurProcessor:
Sharp
Defined in: types.ts:321
Sharp instance to generate blurred images
- Note that blurred images are written to the inline CSS (and cache database) as Base64.
- Must include output option. (
.webp()
.avif()
etc.)
Defult
Section titled “Defult”sharp().resize(20).webp({ quality: 1 })
containerAttributes?
Section titled “containerAttributes?”
optional
containerAttributes:Record
<string
,unknown
> |HTMLAttributes
<"div"
> |HTMLAttributes
<"a"
>
Defined in: types.ts:441
Attributes for container element
crossOrigin?
Section titled “crossOrigin?”
optional
crossOrigin:null
|""
|"anonymous"
|"use-credentials"
Defined in: types.ts:459
Cross origin for preload
densities?
Section titled “densities?”
optional
densities:number
[]
Defined in: types.ts:273
x
descriptors to be used in srcset
- Convert to
0.5x
2x
Example
Section titled “Example”[0.5, 1, 2, 3]
enforceAspectRatio?
Section titled “enforceAspectRatio?”
optional
enforceAspectRatio:boolean
Defined in: types.ts:387
Set CSS property aspect-ratio
to the container element based on width
and height
- Only for
<Background>
component and background mode. - If
width
and/orheight
are not set as properties, the values resolved within the component are used.
format
Section titled “format”format: keyof
ImgProcFormatOptions
Defined in: types.ts:417
Output format
Default
Section titled “Default”"webp"
formatOptions
Section titled “formatOptions”formatOptions:
ImgProcFormatOptions
Defined in: types.ts:429
Format options
jpeg
png
avif
webp
andgif
are allowed.
formats
Section titled “formats”formats: [keyof
ImgProcFormatOptions
,...(keyof ImgProcFormatOptions)[]
]
Defined in: types.ts:423
Output formats
- Last element is used as fallbak format.
Default
Section titled “Default”["avif", "webp"]
height?
Section titled “height?”
optional
height:number
|`${number}`
Defined in: types.ts:267
Image height
layout?
Section titled “layout?”
optional
layout:null
|"constrained"
|"fixed"
|"fullWidth"
|"fill"
Defined in: types.ts:345
Specify the layout of the image
- Apply by adding the global class
globalClassNames.layout[layout]
to the<picture>
and<img>
elements. - If set to
constrained
orfixed
, the CSS propertywidth
of the<img>
element is set to the resolved value as scoped style. - The
<GlobalStyles>
component sets the styles as follows:constrained
:max-width: 100%; height: auto;
fixed
: N/AfullWidth
:width: 100%; height: auto;
fill
:width: 100%; height: 100%;
- Styles can also be defined manually instead of
<GlobalStyles>
using the generated classes.
Default
Section titled “Default”"constrained"
maxAge?
Section titled “maxAge?”
optional
maxAge:number
Defined in: types.ts:455
Maximum value of cache expiration period for remote files (milliseconds)
- Overrides HTTP header specification.
media?
Section titled “media?”
optional
media:string
Defined in: types.ts:290
minAge?
Section titled “minAge?”
optional
minAge:number
Defined in: types.ts:450
Minimum value of cache expiration period for remote files (milliseconds)
- Overrides HTTP header specification.
Default
Section titled “Default”1000 * 60 * 60 * 24 (1day)
objectFit?
Section titled “objectFit?”
optional
objectFit:null
|"none"
|"fill"
|"contain"
|"cover"
|"scale-down"
Defined in: types.ts:355
Set CSS property object-fit
to the <img>
element
- Apply by adding the global class
globalClassNames.objectFit[objectFit]
to the<img>
element. - The
object-fit
is set to this value by the<GlobalStyles>
component. - Styles can also be defined manually instead of
<GlobalStyles>
using the generated classes. - If a default value is required, specify it in the global style.
Default
Section titled “Default”null
objectPosition?
Section titled “objectPosition?”
optional
objectPosition:null
|string
Defined in: types.ts:364
Set CSS property object-position
to the <img>
element
- If
placeholder
isblurred
andbackgroundPosition
isnull
, the value uses forbackground-position
property for blurred image.- If both
objectPosition
andbackgroundPosition
arenull
, then50% 50%
is used.
- If both
- If a default value is required, specify it in the global style.
MDN Reference: object-position
Default
Section titled “Default”null
pictureAttributes?
Section titled “pictureAttributes?”
optional
pictureAttributes:HTMLAttributes
<"picture"
>
Defined in: types.ts:437
Attributes for <picture>
element
placeholder
Section titled “placeholder”placeholder:
null
|"blurred"
|"dominantColor"
Defined in: types.ts:305
Placeholder
dominantColor
: Usesharp().stats().dominant
or the value ofdominantColor
option- Use for
background-color
in BackgroundImage component.
- Use for
blurred
: Use blurred image generated byblurProcessor
- Unavailable for BackgroundImage component.
null
: Disable placeholder
Default
Section titled “Default”"blurred"
placeholderColor?
Section titled “placeholderColor?”
optional
placeholderColor:string
Defined in: types.ts:314
Background color
- If set, use for placeholder instead of dominant color.
- Only works with
placeholder
option isdominantColor
. - Written to the CSS directly.
- Can also use
var(--foo)
.
preload?
Section titled “preload?”
optional
preload: keyof ImgProcFormatOptions
Defined in: types.ts:398
Output <link rel="preload" ... >
- Only one format can be selected.
processor?
Section titled “processor?”
optional
processor:Sharp
|Sharp
[]
Defined in: types.ts:405
Sharp instance to process the image
- Do not use output options except the options about Exif/ICC Profile/Metadata.
Example
Section titled “Example”sharp().grayscale().blur()
profile?
Section titled “profile?”
optional
profile:string
Defined in: types.ts:412
Identifier of image processing profile for caching
- Not necessary for usual.
- If not set, hash of
sharp().options
will be used to identify the processing profile. - If set, this value is used instead of the hash. This is faster than calculating the hash each time.
sizes?
Section titled “sizes?”
optional
sizes:string
| (resolvedWidths
,resolvedDensities
) =>string
Defined in: types.ts:284
Default
Section titled “Default”(min-width: ${widths.at(-1)}px) ${widths.at(-1)}px, 100vw
optional
src:string
Defined in: types.ts:253
Source
- Local path, remote URL or data URL
tagName
Section titled “tagName”tagName: keyof
DefinedIntrinsicElements
Defined in: types.ts:295
Container element tagName
Default
Section titled “Default”"div"
upscale
Section titled “upscale”upscale:
"never"
|"always"
|"original"
Defined in: types.ts:331
How to handle the value of widths/densities that are larger than the image.
always
: Upscale the image to address all values.never
: Ignore values larger than the original image size.- If image real width is
2500
, width prop is1000
and densities prop is[1, 2, 3]
, densities set to[1, 2]
.
- If image real width is
original
: Add the original image size as the largest value.- If image real width is
2500
, width prop is1000
and densities prop is[1, 2, 3]
, densities set to[1, 2, 2.5]
.
- If image real width is
Default
Section titled “Default”"never"
width?
Section titled “width?”
optional
width:number
|`${number}`
Defined in: types.ts:263
Image width
- If
densities
option is used, this value is used as the value of1x
. - If not set and
densities
option is used, the source image is used as the maximum density.
widths?
Section titled “widths?”
optional
widths:number
[]
Defined in: types.ts:279
w
descriptors to be used in srcset
- Convert to
1000w
2000w
Example
Section titled “Example”[1000, 1500, 2000]