Hi, put the following script at the end of functions.php file of your theme:
if (!function_exists('wfu_before_email_notification_handler')) {
function wfu_before_email_notification_handler($changable_data, $additional_data) {
$files = explode(",", $changable_data["filepath"]);
$sizes = array();
foreach ( $files as $file ) array_push($sizes, filesize(trim($file)));
$changable_data["message"] = str_replace("%size%", implode(",", $sizes), $changable_data["message"]);
return $changable_data;
}
add_filter('wfu_before_email_notification', 'wfu_before_email_notification_handler', 10, 2);
}
The put the variable %size% inside the email. It will be replaced by the size of the uploaded file.
Regards
Nickolas
Thread Starter
Marcus
(@omako)
hmm, this causes a fatal error on my site
This means that it was not added correctly (I tested the hook for errors).
If functions.php file ends with ?> symbol, the code must be put above that symbol.
Nickolas
Thread Starter
Marcus
(@omako)
Thank you. I figured it out. Another Plugin caused the Error. Is is possible to show more human readable numbers, like KB oder MB? Sorry to bother you … Best Marcus
Sure, replace the script with the following:
if (!function_exists('wfu_before_email_notification_handler')) {
function wfu_before_email_notification_handler($changable_data, $additional_data) {
$files = explode(",", $changable_data["filepath"]);
$sizes = array();
foreach ( $files as $file ) array_push($sizes, wfu_human_filesize(filesize(trim($file))));
$changable_data["message"] = str_replace("%size%", implode(",", $sizes), $changable_data["message"]);
return $changable_data;
}
add_filter('wfu_before_email_notification', 'wfu_before_email_notification_handler', 10, 2);
}
Regards
Nickolas