ImgProcProcessorOptions
このコンテンツはまだ日本語訳がありません。
Component options
- Part of props
Properties
alt?
optional
alt:string
See
Defined in
artDirectives?
optional
artDirectives:ImgProcArtDirectiveSourceProps
[]
Array of art directive objects
Defined in
asBackground?
optional
asBackground:boolean
Enforce background mode
- Only for
<Image>
and<Picture>
components.
Default
Defined in
backgroundPosition?
optional
backgroundPosition:null
|string
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.
See
MDN Reference: background-position
Default
Defined in
backgroundSize?
optional
backgroundSize:null
|string
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.
See
MDN Reference: background-size
Default
Defined in
blurProcessor
blurProcessor:
Sharp
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
sharp().resize(20).webp({ quality: 1 })
Defined in
containerAttributes?
optional
containerAttributes:Record
<string
,unknown
> |HTMLAttributes
<"div"
> |HTMLAttributes
<"a"
>
Attributes for container element
Defined in
crossOrigin?
optional
crossOrigin:null
|""
|"anonymous"
|"use-credentials"
Cross origin for preload
Defined in
densities?
optional
densities:number
[]
x
descriptors to be used in srcset
- Convert to
0.5x
2x
Example
Defined in
enforceAspectRatio?
optional
enforceAspectRatio:boolean
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.
See
Defined in
format
format: keyof
ImgProcFormatOptions
Output format
Default
Defined in
formatOptions
formatOptions:
ImgProcFormatOptions
Format options
jpeg
png
avif
webp
andgif
are allowed.
See
Defined in
formats
formats: [keyof
ImgProcFormatOptions
,...(keyof ImgProcFormatOptions)[]
]
Output formats
- Last element is used as fallbak format.
Default
Defined in
height?
optional
height:number
| `${number}`
Image height
Defined in
layout?
optional
layout:null
|"constrained"
|"fixed"
|"fullWidth"
|"fill"
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.
See
Default
Defined in
maxAge?
optional
maxAge:number
Maximum value of cache expiration period for remote files (milliseconds)
- Overrides HTTP header specification.
Defined in
media?
optional
media:string
See
Defined in
minAge?
optional
minAge:number
Minimum value of cache expiration period for remote files (milliseconds)
- Overrides HTTP header specification.
Default
Defined in
objectFit?
optional
objectFit:null
|"none"
|"fill"
|"contain"
|"cover"
|"scale-down"
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.
See
Default
Defined in
objectPosition?
optional
objectPosition:null
|string
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.
See
MDN Reference: object-position
Default
Defined in
pictureAttributes?
optional
pictureAttributes:HTMLAttributes
<"picture"
>
Attributes for <picture>
element
Defined in
placeholder
placeholder:
null
|"blurred"
|"dominantColor"
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
Defined in
placeholderColor?
optional
placeholderColor:string
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)
.
See
Defined in
preload?
optional
preload: keyof ImgProcFormatOptions
Output <link rel="preload" ... >
- Only one format can be selected.
Defined in
processor?
optional
processor:Sharp
|Sharp
[]
Sharp instance to process the image
- Do not use output options except the options about Exif/ICC Profile/Metadata.
Example
See
Defined in
profile?
optional
profile:string
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.
Defined in
sizes?
optional
sizes:string
| (resolvedWidths
,resolvedDensities
) =>string
See
Default
(min-width: ${widths.at(-1)}px) ${widths.at(-1)}px, 100vw
Defined in
src?
optional
src:string
Source
- Local path, remote URL or data URL
Defined in
tagName
tagName: keyof
DefinedIntrinsicElements
Container element tagName
Default
Defined in
upscale
upscale:
"never"
|"always"
|"original"
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
Defined in
width?
optional
width:number
| `${number}`
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.
Defined in
widths?
optional
widths:number
[]
w
descriptors to be used in srcset
- Convert to
1000w
2000w