Limit BuddyPress User and Group Avatar File size
You all know that you can limit the dimension of BuddyPress avatars using the constatnts as exlained here.
It is also possible to limit the file size(allowed upload size) for the BuddyPress Avatar.
Here is the code that you can put in your bp-custom.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | /** * Limit BuddyPress Avatar file size. * * @param int $size size in bytes. * @param string $type upload type(avatar, cover_upload). * * @return int */ function buddydev_limit_buddypress_avatar_file_size( $size, $type ) { if ( 'avatar' == $type ) { $size = 20 * 1024; // in bytes, 1024 bytes = 1KB } return $size; } add_filter( 'bp_attachments_get_max_upload_file_size', 'buddydev_limit_buddypress_avatar_file_size', 10,2 ); |
Short and sweet. That's BuddyPress for you!