You can restrict the file size via the wp_handle_upload_prefilter
, where
The single parameter,
$file
, represent a single element of the$_FILES
array.
The code below is just exemplary and untested, but you'll get the point.
add_filter(
'wp_handle_upload_prefilter',
'wpse163236_restrict_upload_file_size'
);
function wpse163236_restrict_upload_file_size( $file ){
$file_size = $file[ 'size' ];
$size_limit = '1024';'1024000';
if ( $size_limit < $file_size ) {
$file[ 'error' ] = 'File Size Over: ' . $size_limit;
}
return $file;
}