ImgProcUserOptions
Defined in: types.ts:28
Image Processor User Options
Extends
Section titled “Extends”Partial
<ImgProcSettings
>
Properties
Section titled “Properties”componentProps?
Section titled “componentProps?”
optional
componentProps:Partial
<Pick
<ImgProcProcessorOptions
,"placeholder"
|"format"
|"tagName"
|"placeholderColor"
|"blurProcessor"
|"upscale"
|"layout"
|"objectFit"
|"objectPosition"
|"backgroundSize"
|"backgroundPosition"
|"enforceAspectRatio"
|"preload"
|"formats"
|"minAge"
|"maxAge"
|"crossOrigin"
>>
Defined in: types.ts:32
Default component properties (user settings)
concurrency?
Section titled “concurrency?”
optional
concurrency:number
Defined in: types.ts:175
Concurrency
Default
Section titled “Default”Math.max(os.cpus().length, 1)
Inherited from
Section titled “Inherited from”Partial.concurrency
dataAdapter?
Section titled “dataAdapter?”
optional
dataAdapter:ImgProcDataAdapter
Defined in: types.ts:210
Data adapter for cache database
Default
Section titled “Default”"astro-image-processor/extras/JsonFileDataAdapter"
Inherited from
Section titled “Inherited from”Partial.dataAdapter
disableCopy?
Section titled “disableCopy?”
optional
disableCopy:boolean
Defined in: types.ts:150
Disable copying from the cache to the output directory
- Refer to the description of
imageOutDirPattern
Default
Section titled “Default”false
Inherited from
Section titled “Inherited from”Partial.disableCopy
downloadDirPattern?
Section titled “downloadDirPattern?”
optional
downloadDirPattern:string
Defined in: types.ts:96
Directory for downloading remote files (pattern)
- Support the following placeholders:
[root]
: Replace withroot
in Astro.[cacheDir]
: Replace withcacheDir
in Astro.[imageCacheDir]
: Replace withimageCacheDir
in this intergration.
Default
Section titled “Default”[imageCacheDir]downloads/
Inherited from
Section titled “Inherited from”Partial.downloadDirPattern
fileNamePattern?
Section titled “fileNamePattern?”
optional
fileNamePattern:string
Defined in: types.ts:144
File name pattern when preserve directory structure option is enabled
- Uses if
preserveDirectories
is true - Support the following placeholders:
[name]
: Original file name (without extension)[hash]
: File hash (full)[hash8]
: File hash (first 8 characters)[width]
: Resolved width[height]
: Resolved height[descriptor]
:1x
2x
1000w
2000w
[ext]
: Extension (without period)
- The file name must include all of
[name]
,[width]
,[height]
, and[descriptor]
, or include[hash8]
or[hash]
- If this condition is not met, different images may be given the same name
- Cache buster can be specified using the hash and query parameter
Default
Section titled “Default”[name]_[width]x[height]@[descriptor].[ext]?[hash8]
Inherited from
Section titled “Inherited from”Partial.fileNamePattern
formatOptions?
Section titled “formatOptions?”
optional
formatOptions:ImgProcFormatOptions
Defined in: types.ts:57
Default format options (user settings)
globalClassNames?
Section titled “globalClassNames?”
optional
globalClassNames:object
Defined in: types.ts:170
Class names used in global CSS
- If change this, need to create and place the corresponding global CSS
cssVariables
Section titled “cssVariables”cssVariables:
object
cssVariables.blurredImage
Section titled “cssVariables.blurredImage”blurredImage:
string
="--aip-blurred-image"
cssVariables.placeholderAnimationState
Section titled “cssVariables.placeholderAnimationState”placeholderAnimationState:
string
="--aip-placeholder-animation-state"
element
Section titled “element”element:
object
element.asBackground
Section titled “element.asBackground”asBackground:
string
="aip-elm-as-background"
element.background
Section titled “element.background”background:
string
="aip-elm-background"
element.container
Section titled “element.container”container:
string
="aip-elm-container"
element.img
Section titled “element.img”img:
string
="aip-elm-img"
element.picture
Section titled “element.picture”picture:
string
="aip-elm-picture"
layout
Section titled “layout”layout:
object
layout.constrained
Section titled “layout.constrained”constrained:
string
="aip-layout-constrained"
layout.fill
Section titled “layout.fill”fill:
string
="aip-layout-fill"
layout.fixed
Section titled “layout.fixed”fixed:
string
="api-layout-fixed"
layout.fullWidth
Section titled “layout.fullWidth”fullWidth:
string
="aip-layout-fullWidth"
Default
Section titled “Default”Configured for <GlobalStyles>
component
Inherited from
Section titled “Inherited from”Partial.globalClassNames
hasher?
Section titled “hasher?”
optional
hasher:ImgProcHasher
Defined in: types.ts:205
Hash generator for buffer and string
- Recommended to use
astro-image-processor/extras/xxHash3Hasher
with xxhash-addon. - If the hasher (or more specifically, the hash algorithm) is changed, caches and database must be cleared.
- Changing the hasher will rename the image files.
Default
Section titled “Default”"astro-image-processor/extras/cryptoHasher"
Inherited from
Section titled “Inherited from”Partial.hasher
imageAssetsDirPattern?
Section titled “imageAssetsDirPattern?”
optional
imageAssetsDirPattern:string
Defined in: types.ts:104
Image assets directory (pattern)
- Support the following placeholders:
[assetsDirName]
: Replaced with_astro
by default Astro settings
- Images placed in
/_astro/[hash].[ext]
by default.
Default
Section titled “Default”/[assetsDirName]/
Inherited from
Section titled “Inherited from”Partial.imageAssetsDirPattern
imageCacheDirPattern?
Section titled “imageCacheDirPattern?”
optional
imageCacheDirPattern:string
Defined in: types.ts:87
Image cache directory (pattern)
- Support the following placeholders:
[root]
: Replace withroot
in Astro.[cacheDir]
: Replace withcacheDir
in Astro.
Default
Section titled “Default”[cacheDir]astro-image-processor/
Inherited from
Section titled “Inherited from”Partial.imageCacheDirPattern
imageOutDirPattern?
Section titled “imageOutDirPattern?”
optional
imageOutDirPattern:string
Defined in: types.ts:114
Image output directory (pattern)
- Support the following placeholders:
[root]
: Replace withroot
in Astro.[outDir]
: Replace withoutDir
in Astro.
- If
disableCopy
istrue
, use this value as path prefix. (Placeholder is disabled)- e.g. Set this value to
https://cdn.example.com/assets/
to generate src/srcset likesrc="https://cdn.example.com/assets/[hash].webp"
, andrsync --update --delete
to synchronizeimageCacheDir
to CDN.
- e.g. Set this value to
Default
Section titled “Default”[outDir]
Inherited from
Section titled “Inherited from”Partial.imageOutDirPattern
preserveDirectories?
Section titled “preserveDirectories?”
optional
preserveDirectories:boolean
Defined in: types.ts:126
Preserve directory structure for image files
- Place images by root relative paths with
srcDir
as the document root - Image filenames are resolved according to
fileNamePattern
- e.g.
- Place the source file in
/src/assets/images/foo/bar.png
and set thesrc
property in the component to the same value - Image output to
/dist/assets/images/foo/[resolved fileNamePattern]
- The
src
andsrcset
of the<img>
element etc. will contain/assets/images/foo/[resolved fileNamePattern]
- Place the source file in
Default
Section titled “Default”false@experimental
Inherited from
Section titled “Inherited from”Partial.preserveDirectories
retentionCount?
Section titled “retentionCount?”
optional
retentionCount:null
|number
Defined in: types.ts:197
Cache retention count
- Delete the cache if not used consecutively in the last
n
builds. - If set to
null
, disables cache deletion by this policy. - If both period and count are enabled, they are processed under
AND
conditions.
Default
Section titled “Default”10
Inherited from
Section titled “Inherited from”Partial.retentionCount
retentionPeriod?
Section titled “retentionPeriod?”
optional
retentionPeriod:null
|number
Defined in: types.ts:189
Cache retention period (ms)
- If not used within the set period, the cache will be subject to deletion
- If set to
null
, disables cache deletion by this policy - If both period and count are enabled, they are processed under
AND
conditions
Default
Section titled “Default”8640000 (100 days)
Inherited from
Section titled “Inherited from”Partial.retentionPeriod
scopedStyleStrategy?
Section titled “scopedStyleStrategy?”
optional
scopedStyleStrategy:"class"
|"attribute"
|"where"
Defined in: types.ts:164
Specify the strategy used for scoping styles
Astro Docs scopedStyleStrategy
Default
Section titled “Default”Inherit Astro settings
Inherited from
Section titled “Inherited from”Partial.scopedStyleStrategy
timeoutDuration?
Section titled “timeoutDuration?”
optional
timeoutDuration:number
Defined in: types.ts:181
Download timeout duration (milliseconds)
- Timeout duration for downloading remote files @default: 5000 (5 seconds)
Inherited from
Section titled “Inherited from”Partial.timeoutDuration
useSrcForHash?
Section titled “useSrcForHash?”
optional
useSrcForHash:boolean
Defined in: types.ts:158
Use the string from the component’s src
property to generate a hash for identifying local image files
- Fast since it doesn’t require reading the image file during hash generation
- However, duplicate files cannot be detected
- Note that files will be recognized as different if the file name or directory changes
Default
Section titled “Default”false
Inherited from
Section titled “Inherited from”Partial.useSrcForHash