Contao Summit 2026 in Leipzig 15th and 16th October

file_icon - Twig Function

Info
This feature is available in Contao 5.7 and later.

With this function you can generate a back end icon based on a file’s type. This is used for the back end in the template of the download(s) content element for example.

The function takes a FilesystemItem as its mandatory argument and also an alt attribute as well as an HtmlAttribute instance as optional arguments.

{{ file_icon(download.file, 'Download', attrs().addClass('file-icon')) }}

Arguments

  • item: The FilesystemItem to generate the file icon for.
  • alt: The string for the alt attribute of the <img>.
  • attributes: An HtmlAttributes instance for additional HTML attributes on the <img>.