I have encountered an use case where I need to modify how uploaded files are displayed in the IMCE file uploader dialog: I want to modify the file name and directory of the uploaded file programmatically, and have those changes be displayed in the dialog. Currently, I resorted to modifying the callback method imce_upload_submit in imce.page.inc by inserting $file alter hooks after

/* more code */
$file->uid = $imce['uid']; //global user may not be the owner.
$file->status = FILE_STATUS_PERMANENT;

/// hook_imce_presave_file_alter
drupal_alter('imce_presave_img', $file);

/* more code */

and a drupal hook

/* more code */
if (isset($form_state['values']['thumbnails']) && img) {
   imce_create_thumbnails( /* ... */ );

/// hook_imce_file_upload
module_invoke_all('imce_img_upload', $file);


Is there a better way to accomplish this?

Please feel free to let me know if you would like more information about what I would like to do.



ufku’s picture

You may use the hooks fired by file_save and/or alter the upload form to add validate/submit handlers to change the workflow.

ufku’s picture

Issue summary:View changes

updated the pre tags to code