File

The File type generates a field for file relations.

Settings

Name Type Default Required
boolean true
string|array ''
integer 99999
integer "0"
string oneToMany
array []

extendedPalette

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 and link. For audio and media files an additional autoplay 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

allowed
Type
string|array
Default
''

Possible values: common-image-types, common-media-types or your custom list of file types.

maxitems

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

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

relationship
Type
string
Default
oneToMany

The relationship defines the cardinality between the relations. Possible values are oneToMany (default), manyToOne and oneToOne. 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, maxitems will be automatically set to 1.

cropVariants

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
Copied!

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
Copied!

Allow media types like audio, video and youtube (or vimeo).

name: example/media
fields:
  - identifier: media
    type: File
    allowed: common-media-types
Copied!

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
Copied!

Usage in Fluid

<f:for each="{data.image}" as="image">
    <f:image image="{image}" width="120" maxHeight="100"/>
</f:for>
Copied!