Component

File link

Default theming and some extra's for Drupal's file links.

 

Making more variables available in Twig

In this component 4 extra variables have been added that are available in the template: 

  • {{ file_uri }} contains the url where the link has to point as a string.
  • {{ mime_type }} contains the type of the file.
  • {{ filename }} contains the name of the file as a string.
  • {{ size }} the size of the file in Kilobytes.

Creating a file link in PHP

You can add a file link by defining it as a render array:

$form['file_field'] = [
  '#theme' => 'file_link',
  '#file' => $file,
  '#description' => $this->t('this is my file'),
];
file-link
Drupal Core
Using Sass
Responsive
Accessible
HTML
CSS
Flat design
0 downloads
horizontal beam No open issue

comments

No comments yet