function template_preprocess_insert_icon_link in Insert 8.2
Same name and namespace in other branches
- 8 insert.module \template_preprocess_insert_icon_link()
- 6 includes/insert.inc \template_preprocess_insert_icon_link()
- 7 includes/insert.inc \template_preprocess_insert_icon_link()
Preprocess variables for the insert-icon-link.html.twig file.
File
- ./
insert.module, line 994
Code
function template_preprocess_insert_icon_link(array &$vars) {
/** @var \Drupal\file\Entity\File $file */
$file = $vars['file'];
$vars['name'] = $file
->getFilename();
$mime_type = $file
->getMimeType();
$vars['type'] = $file
->getMimeType() . '; length=' . $file
->getSize();
$vars['icon_classes'] = join(' ', [
'file',
// Add a specific class for each and every mime type.
'file--mime-' . strtr($mime_type, [
'/' => '-',
'.' => '-',
]),
// Add a more general class for groups of well known MIME types.
'file--' . file_icon_class($mime_type),
]);
}