A preset is a customized version of an image, pre-configured with specific formatting and sizing constraints. You can build customized presets for any image file to tailor your assets as per your business requirements.
The Image Preset Builder app helps you to create and optimize image presets using the Assets Sidebar Widget within the Contentstack environment. It allows you to define parameters such as size, format, quality, compression level, background color, contrast, and other settings of the images in a preset configuration file. It ensures that all images are optimized for web performance while maintaining visual appeal. The app supports JPG, JPEG, and PNG image file formats.
Let's follow this step-by-step guide to install and configure the Image Preset Builder app within your stack.
Follow the steps to install the application in Contentstack.




Additional Resource: For more information on UI locations, please refer to the Installed Apps guide.
To use the Image Preset Builder app within your stack, follow the steps given below:








Image Preset Builder allows you to use varied preset versions of assets across your entries. With the help of this app, you can add image presets to fields such as Custom field and JSON Rich Text Editor field.
To use the Image Presets Builder application within an entry of your stack, follow the steps given below:

There are two ways to add Image Presets in your entry:




Note: You can directly create a new preset version of the selected image to add to the Custom field.
You can view the selected asset or preset in the custom field.





Note: You can directly create a new preset version of the selected image to add to the JSON Rich Text Editor field.
You can view the selected asset or preset in the JSON Rich Text Editor field.

You need to use the Utils functions to render the image presets built using the Image Preset Builder app in your project.
Follow the steps to add the image transformation function to your project, which can help you apply image style and formatting:
Image Preset Builder allows you to build a preset of different styles offered by Contentstack or other CSS building sources. The server will not generate styles for certain scenarios, such as Image Focal Point Definitions and Image Rotation Axis Points. In some transformation projects, you can define CSS styles locally or use third-party packages.
To apply the style and formatting to your image presets, follow the steps:
Now, if applicable, you can handle the focal points of your image preset. To retrieve the focal point coordinates, you can use the fetchPresetByPresetUID() function. This function accepts one object as an argument, and this object requires the asset, presetUID, and extension_uid. You can extract these values from the Custom field or JSON RTE schemas defined in the Field Schema for Reference section. The fetchPresetByPresetUID() function returns a preset object.
Here is an example of the schema for the returned preset object:
{
"uid": "sample-uid",
"name": "Focal Point",
"options": {
"transform": {
"width": 864,
"height": 712
},
"quality": "100",
"image-type": "jpeg",
"focal-point": {
"x": -0.5701133487044711,
"y": 0.030206030249075533
}
}
}
You can retrieve the focal point coordinates from the focal-point object. To render the preset, you need third-party packages that accept the coordinates and display the image accordingly. For example, you can use the image-focus library for JavaScript.
Custom Field
Let's consider that an entry has a Custom field with the name custom-image-field.{
"title": "Preset Picker Demo",
"custom-image-field": {
"uid": "sample-uid",
"metadata": {
"preset": {
"uid": "sample-preset-uid",
...
},
"extension_uid": "sample-extension-uid"
},
"asset": {
"url":"https://example.com/image.jpg",
...
}
}
}
JSON Rich Text Editor Plugin
Let's consider that an entry has a JSON Rich Text Editor field with the name json_rte. This field contains a plugin of type reference.{
"title": "Preset Picker Demo",
"json_rte": {
"uid": "v4-uid",
"children": [
{
"uid": "v4-uid",
"type": "reference",
"attrs": {
"asset-uid": "sample-asset-uid",
"extension_uid": "sample-extension-uid",
"preset": {
"uid": "sample-preset-uid"
},
...
},
"children": [{ "text": "" }]
}
],
"type": "doc"
},
"_embedded_items": {
"json_rte": [
{
"uid": "sample-asset-uid",
"url": "https://example.com/image.jpeg",
...
}
]
},
...
}
Additional Resource: To learn more about Embedded Items in JSON RTE, refer to Embedded Entries or Assets within JSON RTE documentation.