You are here

function itweak_upload_file_icon_url in iTweak Upload 7.3

Creates a URL to the icon for a file object.

Parameters

$file: A file object.

$icon_directory: (optional) A path to a directory of icons to be used for files. Defaults to the value of the "file_icon_directory" variable.

Return value

A URL string to the icon, or FALSE if an appropriate icon cannot be found.

1 call to itweak_upload_file_icon_url()
theme_file_icon_itu in ./itweak_upload.module
Returns HTML for an image with an appropriate icon for the given file.

File

./itweak_upload.module, line 597
iTweakUpload - Tweak attachments display and file upload forms.

Code

function itweak_upload_file_icon_url($file, $icon_directory = NULL) {

  // Try to find extension icon
  if (!empty($icon_directory)) {
    $ext = strtolower(array_pop(explode('.', $file->filename)));
    $icon_path = $icon_directory . '/' . $ext . '.png';
    if (file_exists($icon_path)) {
      return base_path() . $icon_path;
    }
  }

  // If extension icon not found, try mime icons
  return file_icon_url($file, $icon_directory);
}