Asset storage
- 1 minute to read
This non-visual widget provides a mechanism for interacting with asset storage by using Asset Storage API. You can use this widget to populate image galleries, galleries of designs, and font lists.
General info
- type:
asset-storage-ajax
Params
assetType
- one of"designs"
|"images"
|"privatedesigns"
|"privateimages"
|"fonts"
.folder
- a string corresponding to the root folder in storage.folderFilter
-Function
- a function ("{{#function}}") that filters folders received from asset storage. entriesFilter
-Function
- a function ("{{#function}}") that filters entities received from asset storage. previewOptions
- an object describing the required preview images. If asset storage does not contain previews with such options, they will be generated.
Properties
The Asset storage widget returns the following properties :
apiResponse
- a "raw" response from asset storage after applyingfolderFilter
andentriesFilter
if any.response
- a server response in the format ofgallery
items. This object contains an array of elements{name: string, previewUrl: string, path: string}
.
Example
The following example illustrates how you can request designs from asset storage and display them in a gallery widget.
{
"widgets": [
{
"name": "bg-request",
"type": "asset-storage-ajax",
"params": {
"autoCompile": false,
"assetType": "designs",
"folder": "",
"entriesFilter": [
"{{ #function(asset) asset.metadata.surfaces[0].width > 100 }}"
],
"previewOptions": {
"name": "medium",
"namespace": "storefront",
"width": 600,
"height": 600
}
}
},
{
"name": "gallery",
"title": "Gallery",
"type": "gallery",
"params": {
"prompt": "Set a background",
"showTitle": false,
"forceSelection": true,
"items": "{{ $['bg-request'].response }}"
}
}
]
}