1 - I used theme_file_link function to get html link to a file and render that link on to my page.
filename link is displayed but fileicon is not displayed.
code :
$fid = 7;
$file = file_load($fid);
$variables = array();
$variables['file'] = $file;
$icon_path = file_icon_path($file);
$variables['icon_directory'] = $icon_path;
$out .= theme_file_link($variables);
Wrong result : (html code) < img class="file-icon" alt="" title="application/pdf" src="" / >
2 - Result is correct in form used to browse file and download it : fileicon is correctly displayed.
Correct result : (html code) < img class="file-icon" alt="" title="application/pdf" src="/drupal/modules/file/icons/application-pdf.png" / >
Is theme_file_link the right function to render html link with fileicon and filename ?
Which function is used in form API to render managed_file link (see 2) ?
Comments
Theme functions are never
Theme functions are never called directly.
You should be using something like:
But I think that your code has a problem in that icon_directory should be a directory, and you are passing it a file path. You'll need to fix this.
Thank you for your help,
Thank you for your help, following code works correctly.
Rendering of fileicon / filename link on module page :
hook_form to insert/modify and upload file :
hook_form_submit to save file attached to module 'module_name' and object 'object_type' with ID 'object_id' :