Skip to:
Content
Pages
Categories
Search
Top
Bottom

Avatar / Cover Image Maximum File Size Upload


  • @mcuk
    Participant

    @mcuk

    Hi all,

    Trying to set the max file size limit for avatars and cover-images that users are able to upload.

    1. The define ( 'BP_AVATAR_ORIGINAL_MAX_FILESIZE', 1024 ); doesn’t seem to be working. Instead it gives the error message warning that the photo size is too big (even when the photo size is only 200kB). From what I understand, the int constant here is in kB, so am attempting to set the limit at 1 MB (1024kB) while testing.

    2. I have also tried using @imath ‘s code from this link which uses the filter in bp-core-attachments.php line 107: https://buddypress.org/support/topic/upload-failed-error-was-that-photo-is-too-big-please-upload-one-smaller-than/ . This code doesn’t seem to be having any effect on upload size which appears to be somewhere around 2 MB. I can set $size to 1 and still upload images of 1.7MB without a problem.

    add_filter( ‘bp_attachments_get_max_upload_file_size’, function( $size, $type ) {
    	if ( ‘avatar’ === $type ) {
    	$size = 1048576; //1MB in bytes. In practice approx 2MB seems to be upload limit
    	}
    	return $size;
    } );

    Any ideas?

  • You must be logged in to reply to this topic.
Skip to toolbar