Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress Image Size Limit
<?php
function nelio_max_image_size( $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;
}//end if
return $file;
}//end nelio_max_image_size()
add_filter( 'wp_handle_upload_prefilter', 'nelio_max_image_size' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment