File
The File
type generates a field for file relations.
Settings
extendedPalette
-
- Type
- boolean
- Default
- true
If enabled, an additional image or media palette will be rendered. For image files it consists of the additional fields
crop
,alternative
andlink
. For audio and media files an additionalautoplay
field is added. For other file types, like plain text, this option has no effect. Disable this option, if you don't need these additional fields.
allowed
-
- Type
- string|array
- Default
- ''
Possible values:
common-
,image- types common-
or your custom list of file types.media- types
maxitems
-
- Type
- integer
- Default
- 99999
Maximum number of child items. Defaults to a high value. JavaScript record validation prevents the record from being saved if the limit is not satisfied.
minitems
-
- Type
- integer
- Default
- "0"
Minimum number of child items. Defaults to 0. JavaScript record validation prevents the record from being saved if the limit is not satisfied. The field can be set as required by setting
minitems
to at least 1.
relationship
-
- Type
- string
- Default
- oneToMany
The relationship defines the cardinality between the relations. Possible values are
one
(default),To Many many
andTo One one
. In case of a [x]toOne relation, the processed field will be filled directly with the file reference instead of a collection of file references. In addition,To One maxitems
will be automatically set to1
.
cropVariants
-
- Type
- array
- Default
- []
It is possible to define crop variants for this specific field and Content Block. This documentation only covers the most basic configuration. Refer to the TCA documentation for a complete overview of possibilities.
Example configuration below. The aspect ratios can be defined as a float value or a fraction. Only the simple division operation
a / b
is allowed.cropVariants: teaser: title: Teaser allowedAspectRatios: portrait: title: Portrait value: 0.75 landscape: title: Landscape value: 4 / 3
Copied!
Example
Minimal
All file types allowed, no restrictions.
name: example/file
fields:
- identifier: my_file_field
type: File
Advanced / use case
Allow only image types, disable extended palette (no cropping field), require at least one image and set limit to 10 images.
name: example/image
fields:
- identifier: image
type: File
extendedPalette: false
minitems: 1
maxitems: 10
allowed: common-image-types
Allow media types like audio, video and youtube (or vimeo).
name: example/media
fields:
- identifier: media
type: File
allowed: common-media-types
Set specific crop variants for an image field.
name: example/image
fields:
- identifier: image
type: File
allowed: common-image-types
cropVariants:
desktop:
title: Desktop
allowedAspectRatios:
portrait:
title: Portrait
value: 0.75
landscape:
title: Landscape
value: 4 / 3
focusArea:
x: 0.3
y: 0.3
width: 0.4
height: 0.4
coverAreas:
- x: 0.1
y: 0.8
width: 0.8
height: 0.1
tablet:
title: Tablet
allowedAspectRatios:
square:
title: Square
value: 0.75
smartphone:
title: Smartphone
allowedAspectRatios:
landscape:
title: Landscape
value: 4 / 3
Usage in Fluid
<f:for each="{data.image}" as="image">
<f:image image="{image}" width="120" maxHeight="100"/>
</f:for>