Can I limit file size or image uploaded?
Yes, you must use the following filters.
If you want to limit the size of file upload, you have to use the filter «bxcft_files_max_filesize». The following code shows how to limit the file size to 2MB.
1 2 3 4 |
add_filter( 'bxcft_files_max_filesize', 'my_files_max_filesize', 10, 2 ); function my_files_max_filesize($current_filesize) { return 2; } |
If you want to limit the size of image upload, you have to use the filter «bxcft_images_max_filesize». The following code shows how to limit the file size to 10MB.
1 2 3 4 |
add_filter( 'bxcft_images_max_filesize', 'my_images_max_filesize', 10, 2 ); function my_images_max_filesize($current_filesize) { return 10; } |
By default, the maximum size is set to 8MB for both files and images.
Remember that if you use these filters, the php.ini variables «upload_max_filesize» and «post_max_size» will always prevail over this filter.