You are here

function template_preprocess_insert_icon_link in Insert 8

Same name and namespace in other branches
  1. 8.2 insert.module \template_preprocess_insert_icon_link()
  2. 6 includes/insert.inc \template_preprocess_insert_icon_link()
  3. 7 includes/insert.inc \template_preprocess_insert_icon_link()

Preprocess variables for the insert-icon-link.html.twig file. Basically a slimmed copy of template_preprocess_file_link() with the exception that it will consistently apply absolute or relative URLs, according to the Insert setting.

File

./insert.module, line 254

Code

function template_preprocess_insert_icon_link(&$vars) {

  /** @var File $file */
  $file = $vars['file'];
  $vars['name'] = $file
    ->getFilename();
  $mime_type = $file
    ->getMimeType();
  $vars['type'] = $file
    ->getMimeType() . '; length=' . $file
    ->getSize();
  $vars['icon_classes'] = join(' ', array(
    'file',
    // Add a specific class for each and every mime type.
    'file--mime-' . strtr($mime_type, array(
      '/' => '-',
      '.' => '-',
    )),
    // Add a more general class for groups of well known MIME types.
    'file--' . file_icon_class($mime_type),
  ));
}