- Description:
This key defines options that are specific to File Inputs.
- Appears in:
└── _inputs └── * └── File Input └── options- Type:
Object- Properties:
This key defines which file types are available to select or upload to this input.
Accepted format is an array or comma-separated string of MIME types.
The special value "*" means any type is accepted.
Show examplesHide examples
In this example, we have configured a Image Input to accept only JPEG or PNG files.
Copied to clipboard_inputs: featured_image: type: image options: accepts_mime_types: - image/jpeg - image/png{ "_inputs": { "featured_image": { "type": "image", "options": { "accepts_mime_types": [ "image/jpeg", "image/png" ] } } } }This key defines which sources and DAMs you are allowed to upload to and browse.
The value can be an array of strings. Valid values include
site-filesand the reference key for any DAM connected to your site.If
site-filesis omitted from the array, site files will not be available as an asset source for this input.Show examplesHide examples
In this example, we have configured allowed sources for an Image Input.
Copied to clipboard_inputs: image: type: image options: allowed_sources: - site-files - my-cloudinary-dam{ "_inputs": { "image": { "type": "image", "options": { "allowed_sources": [ "site-files", "my-cloudinary-dam" ] } } } }This key toggles whether CloudCannon will prevent typing into the Text Input, while still allowing context menu options to change the value.
Setting this key to
truewill prevent typing into the Text Input.Defaults to:
falseShow examplesHide examples
In this example, CloudCannon will prevent typing into the Text Input
url.Copied to clipboard_inputs: url: type: url options: disable_direct_input: true{ "_inputs": { "url": { "type": "url", "options": { "disable_direct_input": true } } } }This key toggles whether CloudCannon will disable the context menu option and the drop area for uploading files.
Setting this key to
truewill disable the context menu option and prevent uploading file through drag-and-drop in a File Input.Defaults to:
falseShow examplesHide examples
In this example, CloudCannon will disable the option to upload a file in the context menu and prevent uploading file through drag-and-drop in a File Input.
Copied to clipboard_inputs: image: type: image options: disable_upload_file: true{ "_inputs": { "image": { "type": "image", "options": { "disable_upload_file": true } } } }This key toggles whether CloudCannon will prevent file uploads inside the "Select existing file/image" file browser modal window.
Setting this key to
truewill prevent file uploads inside the file browser modal window.Defaults to:
falseShow examplesHide examples
In this example, CloudCannon will disable the option to upload files inside the file browser modal window.
Copied to clipboard_inputs: image: type: file options: disable_upload_file_in_file_browser: true{ "_inputs": { "image": { "type": "file", "options": { "disable_upload_file_in_file_browser": true } } } }This key defines how an 'empty' value will be saved. Does not apply to existing empty values.
Defaults to:
nullAllowed values:
nullstringThis key defines whether you can upscale an image to fit the bounding box while resizing an image prior to upload.
Has no effect if files are not resized.
Defaults to:
falseShow examplesHide examples
In this example, we have configured an Image Input to allow upscaling images to fit the bounding box while resizing.
Copied to clipboard_inputs: hero_image: type: image options: width: 1200 height: 600 resize_style: cover expandable: true{ "_inputs": { "hero_image": { "type": "image", "options": { "width": 1200, "height": 600, "resize_style": "cover", "expandable": true } } } }This key defines the height of the bounding box used in the resizing method defined by
resize_style.Show examplesHide examples
In this example, we have configured the height of the bounding box for an Image Input.
Copied to clipboard_inputs: hero_image: type: image options: width: 1200 height: 600 resize_style: cover{ "_inputs": { "hero_image": { "type": "image", "options": { "width": 1200, "height": 600, "resize_style": "cover" } } } }This key toggles whether CloudCannon will instruct a rich text editor to save
widthandheightattributes on image elements.Setting this key to
truewill instruct the rich text editor to savewidthandheightattributes on image elements. This can prevent pop-in as a page loads.By default, this key is
false(i.e., width and height attributes are not saved on image elements). This defaults totrueif the Image Size Attributes site flag is enabled (this is enabled for sites created before June 23 2023, in order to keep those sites working).Defaults to:
trueShow examplesHide examples
In this example, CloudCannon will save width and height attributes on image elements in a Rich Text Input.
Copied to clipboard_inputs: content: type: markdown options: image_size_attributes: true{ "_inputs": { "content": { "type": "markdown", "options": { "image_size_attributes": true } } } }This key defines the locale that CloudCannon uses to determine the number of words or graphemes in this Input, if you have
max_words,min_words,max_graphemes, ormin_graphemesconfigured.This key defines the maximum file size in kB that CloudCannon will allow you to upload.
When configured, CloudCannon will prevent you from saving your changes until you select a valid file size, or discard your unsaved changes.
Value can be any positive integer.
This key has no default.
This key is available for File and URL Inputs.
Show examplesHide examples
In this example, we want our team to upload an image using the
feature_imageInput. This Input limits you to a maximum file size of 750 kB.Copied to clipboard_inputs: feature_image: type: image comment: Select the feature image for the banner. options: max_file_size: 140{ "_inputs": { "feature_image": { "type": "image", "comment": "Select the feature image for the banner.", "options": { "max_file_size": 140 } } } }This key defines a custom error message that explains why a value has failed the validation criteria from
options.max_file_size. This key requires you to defineoptions.max_file_size.This key has no default.
This key is available for File and URL Inputs.
Show examplesHide examples
In this example, we want our team to upload an image using the
feature_imageInput. This Input limits you to a maximum file size of 750 kB.Copied to clipboard_inputs: feature_image: type: image comment: Select the feature image for the banner. options: max_file_size: 140 max_file_size_message: For SEO, keep this under 140kB{ "_inputs": { "feature_image": { "type": "image", "comment": "Select the feature image for the banner.", "options": { "max_file_size": 140, "max_file_size_message": "For SEO, keep this under 140kB" } } } }This key defines the maximum string length, in graphemes, that CloudCannon will allow in an Input. When configured, CloudCannon will warn you when an Input value is too long. If the Input already contains a longer value, CloudCannon will require you to remove characters until the Input contains a valid string to save your changes, or discard your unsaved changes.
This key defines the message that explains which maximum string length an Input will accept. This key requires you to define `options.max_graphemes.
This key defines the maximum string length, in characters, that CloudCannon will allow in an Input.
When configured, CloudCannon will warn you when an Input value is too long.
If the Input already contains a longer value, CloudCannon will require you to remove characters until the Input contains a valid string to save your changes, or discard your unsaved changes.
Value can be any non-negative integer.
If this key is set to
0, CloudCannon requires the Input to be empty.If
options.min_lengthis also configured, this key cannot be a smaller number.This key has no default.
This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs.
To use this key in a Select Input,
allow_createmust be set totrue.Show examplesHide examples
In this example, we want our team to enter a blog description using the Rich Text
seo_descriptionInput. This Input limits you to a maximum of 125 characters.Copied to clipboard_inputs: seo_description: type: markdown comment: Enter a brief description of this blog. options: max_length: 125 min_length: 25{ "_inputs": { "seo_description": { "type": "markdown", "comment": "Enter a brief description of this blog.", "options": { "max_length": 125, "min_length": 25 } } } }This key defines a custom error message that explains why a value has failed the validation criteria from
options.max_length.This key requires you to define
options.max_length.This key has no default.
This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs.
Show examplesHide examples
In this example, we prompt our team to enter a valid number of characters using a custom message.
Copied to clipboard_inputs: seo_description: type: markdown comment: Enter a brief description of this blog. options: max_length: 125 max_length_message: You are only allowed 125 characters. min_length: 25 min_length_message: Please write more than 25 characters.{ "_inputs": { "seo_description": { "type": "markdown", "comment": "Enter a brief description of this blog.", "options": { "max_length": 125, "max_length_message": "You are only allowed 125 characters.", "min_length": 25, "min_length_message": "Please write more than 25 characters." } } } }This key defines the maximum string length, in words, that CloudCannon will allow in an Input. When configured, CloudCannon will warn you when an Input value is too long. If the Input already contains a longer value, CloudCannon will require you to remove characters until the Input contains a valid string to save your changes, or discard your unsaved changes.
This key defines the message that explains which maximum string length an Input will accept. This key requires you to define `options.max_words.
This key defines what format an image is converted to prior to upload.
Allowed values:
image/jpegimage/pngimage/webpShow examplesHide examples
In this example, we have configured an Image Input to convert images to WebP format prior to upload.
Copied to clipboard_inputs: hero_image: type: image options: mime_type: image/webp{ "_inputs": { "hero_image": { "type": "image", "options": { "mime_type": "image/webp" } } } }This key defines the minimum string length, in graphemes, that CloudCannon will allow in an Input. When configured, CloudCannon will warn you when an Input value is too short. If the Input already contains a shorter value, CloudCannon will require you to add characters until the Input contains a valid string to save your changes, or discard your unsaved changes.
This key defines the message that explains which minimum string length an Input will accept. This key requires you to define
options.min_graphemes.This key defines the minimum string length, in characters, that CloudCannon will allow in an Input.
When configured, CloudCannon will warn you when an Input value is too short.
If the Input already contains a shorter value, CloudCannon will require you to add characters until the Input contains a valid string to save your changes, or discard your unsaved changes.
Value can be any positive integer.
If
options.max_lengthis also configured, this key cannot be a greater number.This key has no default.
This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs.
To use this key in a Select Input,
allow_createmust be set totrue.Show examplesHide examples
In this example, we want our team to enter a blog description using the Rich Text
seo_descriptionInput. This Input requires a minimum of 25 characters.Copied to clipboard_inputs: seo_description: type: markdown comment: Enter a brief description of this blog. options: max_length: 125 min_length: 25{ "_inputs": { "seo_description": { "type": "markdown", "comment": "Enter a brief description of this blog.", "options": { "max_length": 125, "min_length": 25 } } } }This key defines a custom error message that explains why a value has failed the validation criteria from
options.min_length.This key requires you to define
options.min_length.This key has no default.
This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs.
Show examplesHide examples
In this example, we prompt our team to enter a valid number of characters using a custom message.
Copied to clipboard_inputs: seo_description: type: markdown comment: Enter a brief description of this blog. options: max_length: 125 max_length_message: You are only allowed 125 characters. min_length: 25 min_length_message: Please write more than 25 characters.{ "_inputs": { "seo_description": { "type": "markdown", "comment": "Enter a brief description of this blog.", "options": { "max_length": 125, "max_length_message": "You are only allowed 125 characters.", "min_length": 25, "min_length_message": "Please write more than 25 characters." } } } }This key defines the minimum string length, in words, that CloudCannon will allow in an Input. When configured, CloudCannon will warn you when an Input value is too short. If the Input already contains a shorter value, CloudCannon will require you to add characters until the Input contains a valid string to save your changes, or discard your unsaved changes.
This key defines the message that explains which minimum string length an Input will accept. This key requires you to define
options.min_words.This key defines paths for your Rich Text editors or File inputs.
If undefined at higher levels of the configuration cascade,
pathswill default to any values configured in the CloudCannon configuration file.Show examplesHide examples
In this example, we have configured paths for the
blogCollection to set custom upload and static paths.Copied to clipboardcollections_config: blog: paths: uploads: /uploads/blog/ static: /assets/{ "collections_config": { "blog": { "paths": { "uploads": "/uploads/blog/", "static": "/assets/" } } } }This key defines a regular expression that the Input value must match.
When configured, CloudCannon will require you to enter a value that matches the REGEX pattern.
If the Input already contains an invalid value, CloudCannon will require you to enter a valid string to save your changes, or discard your unsaved changes.
Value must be a valid REGEX string.
If your REGEX string includes a
\character and CloudCannon Configuration File is a.ymlfile, use single quotes'around the string to avoid a build error.This key has no default.
This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs.
To use this key in a Select Input,
allow_createmust be set totrue.Show examplesHide examples
In this example, we want our team to add an email address to the
contact_emailInput using the correct email format.Copied to clipboard_inputs: contact_email: type: email options: pattern: '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' pattern_message: Please use the format ___@___.__{ "_inputs": { "contact_email": { "type": "email", "options": { "pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}", "pattern_message": "Please use the format ___@___.__" } } } }This key defines the flags (e.g. case-insensitive searching) for the regular expression set in
options.pattern.Show examplesHide examples
In this example, we have configured pattern flags for a text input to enable case-insensitive searching.
Copied to clipboard_inputs: search_term: type: text options: pattern: ^[a-z]+$ pattern_flags: ignore_case: true{ "_inputs": { "search_term": { "type": "text", "options": { "pattern": "^[a-z]+$", "pattern_flags": { "ignore_case": true } } } } }This key defines a custom error message that explains why a value has failed the validation criteria from
options.pattern.This key requires you to define
options.pattern.This key has no default.
This key is available for Code, Color, File, Select, Text, Rich Text, and URL Inputs.
Show examplesHide examples
In this example, we prompt our team to use the correct email format in the
contact_emailInput using a pattern message.Copied to clipboard_inputs: contact_email: type: email options: pattern: '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}' pattern_message: Please use the format ___@___.__{ "_inputs": { "contact_email": { "type": "email", "options": { "pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}", "pattern_message": "Please use the format ___@___.__" } } } }This key toggles whether CloudCannon will skip the image resizing process configured for this input when selecting existing images.
Setting this key to
truewill skip the image resizing process when selecting existing images.Defaults to:
falseShow examplesHide examples
In this example, CloudCannon will skip the image resizing process when selecting existing images for an Image Input.
Copied to clipboard_inputs: hero_image: type: image options: width: 1200 height: 600 resize_style: cover prevent_resize_existing_files: true{ "_inputs": { "hero_image": { "type": "image", "options": { "width": 1200, "height": 600, "resize_style": "cover", "prevent_resize_existing_files": true } } } }This key toggles whether CloudCannon requires this Input to have a value.
Setting this key to
truewill require you to enter a value to save your changes, or discard your unsaved changes.By default, this key is
false(i.e., CloudCannon does not require this Input to have a value).This key is available for Array, Code, Color, Date and Time, File, Number, Object, Select and Multiselect, Text, Rich Text, and URL Inputs.
Defaults to:
falseShow examplesHide examples
In this example, we want to require our team to enter an
authorvalue for markup files with this Input.Copied to clipboard_inputs: author: type: text comment: Enter the name of the author for this blog post. options: required: true{ "_inputs": { "author": { "type": "text", "comment": "Enter the name of the author for this blog post.", "options": { "required": true } } } }This key defines a custom error message that explains why a value has failed the validation criteria from
options.required.This key requires you to define
options.required.This key has no default.
This key is available for Array, Code, Color, Date and Time, File, Number, Object, Select and Multiselect, Text, Rich Text, and URL Inputs.
Show examplesHide examples
In this example, we prompt our team to use enter an Input value using a required message.
Copied to clipboard_inputs: author: type: text comment: Enter the name of the author for this blog post. options: required: true required_message: You are not allowed to leave this blank.{ "_inputs": { "author": { "type": "text", "comment": "Enter the name of the author for this blog post.", "options": { "required": true, "required_message": "You are not allowed to leave this blank." } } } }This key defines how image files are resized prior to upload, using a bounding box defined by
widthandheightoptions.Valid values are
cover,contain,crop, orstretch:coverkeeps aspect ratio and ensures the image covers the bounding boxcontainkeeps aspect ratio and ensures the image fits inside the bounding boxcropprompts the user with and interface to select an aspect-ratio-respecting areastretchignores aspect ratio and resizes the image to the bounding box
This key does not apply to existing images, and does not work if
widthandheightoptions are not defined.Defaults to:
containAllowed values:
covercontainstretchcropShow examplesHide examples
In this example, we have configured an Image Input to resize images using the
coverstyle to ensure images cover the bounding box while maintaining aspect ratio.Copied to clipboard_inputs: hero_image: type: image options: width: 1200 height: 600 resize_style: cover{ "_inputs": { "hero_image": { "type": "image", "options": { "width": 1200, "height": 600, "resize_style": "cover" } } } }This key defines definitions for creating additional images of different sizes when uploading or selecting existing files.
Show examplesHide examples
In this example, we have configured an Image Input to create additional images of different sizes when uploading or selecting files.
Copied to clipboard_inputs: hero_image: type: image options: sizes: - size: 2x - size: 3x{ "_inputs": { "hero_image": { "type": "image", "options": { "sizes": [ { "size": "2x" }, { "size": "3x" } ] } } } }- Examples: