Home › Forums › Support › I want to limit max file upload size in WP › Reply To: I want to limit max file upload size in WP
April 9, 2016 at 8:39 am
#185537
Tom
Lead Developer
Lead Developer
Hi Joanne,
This is why it’s always good to prefix functions to avoid conflict.
So you could do this instead:
add_filter("adverts_gallery_upload_prefilter", "joanne_limit_file_uploads");
function joanne_limit_file_uploads( $file ) {
if ( !isset($file["name"]) || !isset($file["type"]) ) {
return $file;
}
if ( !isset( $_POST["post_id"] ) ) {
$post_id = 0;
} else {
$post_id = intval($_POST["post_id"]);
}
if( $file["size"] >= 1000000 ) {
$file["error"] = "Your file is to big.";
}
return $file;
}