/** * Returns HTML for an image with an appropriate icon for the given file. * * @param $variables * An associative array containing: * - file: A file object for which to make an icon. * - 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. * * @ingroup themeable */ function kivnew_file_icon($variables) { $retst=""; $file = $variables['file']; $icon_directory = $variables['icon_directory']; $mime = check_plain($file->filemime); $icon_url = file_icon_url($file, $icon_directory); $retst = '<img class="file-icon" alt="START'. base_path() .'" title="' . $mime . '" src="' . $icon_url . '" />'; if($mime == "application/pdf"){ // tabort bilden framför om det är en pdf $retst =""; // Detta är om man vill lägga till egen icon framför: //$retst = '<img class="file-icon" alt="START" title="' . $mime . '" src="'. $GLOBALS['base_url'] .'/sites/all/themes/kivnew/images/icondownarrow.png" />'; // sköter det via css istället } if($mime == "audio/mpeg"){ // tabort bilden framför om det är en ljudfil $retst=""; } return $retst; }
/** * Callback for icon url */ public function getIconUrl($wrapper) { $file = $wrapper->value(); return file_icon_url($file); }
/** * Change the directory of the file's icons. * * Implements hook_file_icon(). * * @param $variables * * @return string */ function base_file_icon($variables) { $file = $variables['file']; $icon_directory = drupal_get_path('theme', 'base') . '/images/doc-types'; $mime = check_plain($file->filemime); $icon_url = file_icon_url($file, $icon_directory); return '<img alt="' . $mime . '" class="file-icon" src="' . $icon_url . '" title="" width="56" height="74" />'; }
/** * Override theme_file_icon() */ function peace_file_icon($variables) { $file = $variables['file']; $icon_directory = $variables['icon_directory']; $mime = check_plain($file->filemime); // Add a clickeable larger pdf icon if ($mime == 'application/pdf') { $icon_directory = drupal_get_path('theme', 'peace') . '/images/icons'; $icon_url = file_icon_url($file, $icon_directory); $html = '<div><a href="' . file_create_url($file->uri) . '"><img class="file-icon" alt="" title="' . $mime . '" src="' . $icon_url . '" /></a></div>'; } else { $icon_url = file_icon_url($file, $icon_directory); $html = '<img class="file-icon" alt="" title="' . $mime . '" src="' . $icon_url . '" />'; } return $html; }