Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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);
file_save($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.
Knight
Comments
Comment #1
ufku CreditAttribution: ufku commentedYou may use the hooks fired by file_save and/or alter the upload form to add validate/submit handlers to change the workflow.
Comment #1.0
ufku CreditAttribution: ufku commentedupdated the pre tags to code
Comment #2
thallesI think this was solved!
Comment #3
thalles