Created
September 19, 2018 14:41
-
-
Save geoclaps/1f4a51be21471d650feac9af93e4abf6 to your computer and use it in GitHub Desktop.
Wordpress upload limit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function upload_limits($file) { | |
$size = $file['size']; | |
$size = $size / 1024; | |
$type = $file['type']; | |
$is_image = strpos( $type, 'image' ) !== false; | |
$limit = 250; | |
$limit_output = '250kb'; | |
if ( $is_image && $size > $limit ) { | |
$file['error'] = 'Image files must be smaller than ' . $limit_output; | |
} | |
return $file; | |
} | |
add_filter( 'wp_handle_upload_prefilter', 'upload_limits' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment