Creates a URL to the icon for a file entity.
Drupal\file\File $file: A file entity.
$icon_directory: (optional) A path to a directory of icons to be used for files. Defaults to the value of the "icon.directory" variable.
A URL string to the icon, or FALSE if an appropriate icon cannot be found.
function file_icon_url(File $file, $icon_directory = NULL) {
if ($icon_path = file_icon_path($file, $icon_directory)) {
return base_path() . $icon_path;
}
return FALSE;
}