The image component is used to display images.
Below are two examples of the schema required to define an Image.
{
"type": "Image",
"options": {
"image_url": "https://image.io/ijoh943.jpg"
}
},
{
"type": "Image",
"options": {
"base64": "poiu49ht3...",
"caption": "Lorem ipsum dolor sit amet"
}
}
Key | Description |
---|---|
image_url |
The URL of the image. Only JPG, PNG, GIF and WebP supported. (Optional if base64 is specified.) |
base64 |
Optional. Base64 encoded string of the image. |
base64_extension |
Optional. The extension of the base64 encoded image data. Defaults to png . Allowed values include jpeg and png . |
width |
Optional. The width of the component, when inside a Section or Row component with their columns option set to null . |
caption |
Optional. Caption to add below the image. |
When using the
image_url
key, ensure the image you are linking to has a size of less than 2 MB.
By default, the images will be scaled proportionally to fit within the confines of the region of the report they are added to. This means there may be white space around the image, as it attempts to maintain the aspect ratio.
The width
key supports defining the width using a fraction specified as a
string e.g. 1/3
. The values for the denominator supported are 2, 3, 4, 5, 6
and 12, whilst the numerator can be any value up to the value of the denominator.
If the width
key is set to null
, then the component will attempt to fill
all the available horizontal space.
Images can be provided in one of two ways, either via providing an external
web-accessible URL, or by base64 encoding the image. Providing an external
URL is the preferred way, as this greatly reduces the size of the JSON payload
being POSTed to the API. Please note, you should only specify either the
image_url
key or the base64
key.
The recommended way to provide a URL for your image is to host it on a cloud storage solution such as Amazon S3 / Google Cloud Storage buckets / Azure Blob Storage. The supported image formats are:
If hosting your image is not an option, you can base 64 encode the image and
provide the string in the base64
key. Please ensure the base 64 encoded string
is using the UTF-8 character set.
Hybiscus is continuously improving and adding new features. If you think we are missing a critical feature, please do not hesitate to contact us and offer your feedback at info@hybiscus.dev