Create Thumbnail
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Tokens,Forms
Makes a resized copy of an image, for example a small preview of a photo a user uploaded, and saves it in a portal folder. You choose the size, whether the image is cropped to fit exactly, and the image quality. The original image isn't changed.
This action requires the Drawing feature package to be licensed. If it isn't, the action fails with a not-licensed error.
Typical Use Cases
- Create a small preview of a profile photo or product image when a form is submitted
- Create a square thumbnail for a gallery by cropping the center of the image
- Reduce the size of large uploaded photos before showing them on a page
- Create a thumbnail for each file in a multiple file upload
Don't use it to
- Change the file format, for example from PNG to JPEG. The thumbnail keeps the original file's format and extension.
- Edit the original image. The action always saves a new file.
- Process PDFs or documents. It only works with images.
Related Actions
| Action Name | Description |
|---|---|
| Get or Create Folder | Creates the folder for the thumbnails ahead of time and returns its details. |
| Copy File | Copies a file without changing it. |
| Delete File | Deletes a thumbnail you no longer need. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Image | The image to resize. In button actions, pick a Single File Upload field. In the actions of a multiple file upload, switch to an expression and use a token such as [AbsoluteUrl]. If it's empty, or the file isn't found, the action does nothing. | Yes | empty | Yes |
| Output Folder | The portal folder to save the thumbnail in. It's created if it doesn't exist. | Yes | empty | Yes |
| Name | The thumbnail's file name, without the extension, for example [UserID]-small. The original file's extension is added. | Yes | empty string | Yes |
| Width | The thumbnail's width in pixels. | Yes | empty string | See below |
| Height | The thumbnail's height in pixels. | Yes | empty string | See below |
| Crop | When checked, the thumbnail is exactly Width × Height, and the parts of the image that don't fit are cut off. When unchecked, the whole image is kept and fitted inside that size. | No | Unchecked | No |
| Stretch | When checked, small images are enlarged to reach the size. When unchecked, images are never made bigger than they are. | No | Unchecked | No |
| Horizontal | Which part of the image to keep when cropping sideways: Left, Center or Right. | Yes | Center | No |
| Vertical | Which part of the image to keep when cropping up and down: Top, Center or Bottom. | Yes | Center | No |
| Compression | The image quality, from 1 (smallest file, lowest quality) to 100 (best quality). It mainly affects JPEG images. Empty or 0 saves with the default quality. | Yes | empty string | No |
| Token Name | The name of the output token. See Output Parameters Reference. | Yes | thumbnail | No |
At least one of Width and Height is required. If you give only one, the other is calculated so that the image keeps its proportions.
Output Parameters Reference
The action creates these tokens, using Token Name. If Token Name is empty, they start with thumbnail, for example [thumbnail:AbsoluteUrl].
| Token | Contains |
|---|---|
[<TokenName>:FileId] | The ID of the thumbnail file. |
[<TokenName>:FileName] | The file name without the extension. |
[<TokenName>:FileExtension] | The extension, without the dot, for example jpg. |
[<TokenName>:FileNameAndExtension] | The file name with the extension. |
[<TokenName>:FilePath] | The physical path on the server. |
[<TokenName>:RelativeUrl] | A LinkClick URL for the file, relative to the site. |
[<TokenName>:AbsoluteUrl] | A full LinkClick URL for the file. |
[<TokenName>:NormalRelativeUrl] | The direct URL of the file, relative to the site. Use this in an <img> tag. |
[<TokenName>:NormalAbsoluteUrl] | The full direct URL of the file. |
[<TokenName>:Base64] | The file's content, Base64 encoded. |
[<TokenName>:MimeType] | The file's content type, for example image/jpeg. |
[<TokenName>:FileSize] | The file size in a readable form. :FileSizeB, :FileSizeKB, :FileSizeMB and :FileSizeGB give the size in a specific unit. |
When the image comes from a Single File Upload field, the action also sets [<FieldName>:FileOrThumbnailNameAndExtension] to the thumbnail's file name.
In the actions of a multiple file upload, it adds each thumbnail to comma-separated lists in [<FieldName>:ThumbanilUrls], [<FieldName>:ThumbanilNames] and [<FieldName>:ThumbanilIds]. The misspelling "Thumbanil" is how the product names these tokens.