You are here

function asset_file_img in Asset 6

Same name and namespace in other branches
  1. 5.2 asset.types.inc \asset_file_img()

Implementation of hook_asset_type('img') for file asset type

File

./asset.types.inc, line 228
This file is included by asset_asset_type() and includes all the file and directory specific functions

Code

function asset_file_img($asset) {
  if (strpos($asset->file['filemime'], 'image/') === 0) {
    return file_create_path($asset->file['filepath']);
  }
  $path = pathinfo($asset->file['filepath']);
  $icon = drupal_get_path('module', 'asset') . '/icons/' . $path['extension'] . '.png';
  if (file_exists($icon)) {
    return $icon;
  }
}