#28878 closed enhancement (invalid)
Create a filter to customize the fileupload_maxk value
Reported by: | virgodesign | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.9.1 |
Component: | Upload | Keywords: | |
Focuses: | Cc: |
Description
In a wordpress multisite environment the max uploadable file size is setted globally at network level and it is unique for all blogs.
It's not possible to customize it, for example, for specific themes or user role.
Applying a filter to this value it will give the ability to customize the max file upload size.
Change History (4)
#2
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Hi virgodesign,
This is currently possible in multiple ways:
- For core upload workflows, by filtering on the upload_size_limit hook just as core already does for Multisite in wp-includes/ms-functions.php, but on a later priority. For example:
<?php /** * Filter the upload size limit for non-administrators. * * @param string $size Upload size limit (in bytes). * @return int (maybe) Filtered size limit. */ function filter_upload_size_limit( $size ) { $site = get_current_site(); // Set the upload size limit to 10 MB for non-administrators of site 1. if ( ! current_user_can( 'manage_options' ) && 1 === $site->id ) { // 10 MB. $size = 1024 * 10000; } return $size; } add_filter( 'upload_size_limit', 'filter_upload_size_limit', 20 );
- Directly, as alluded to by @ocean90 above. For instance, filtering the option on the pre_site_option_{$option} hook (
pre_site_option_fileupload_maxk
) would do it, though the issue there is that the core filter, upload_size_limit_filter takes the lowest of the incoming size and option value for core upload workflows.
#4
in reply to:
↑ 3
@
10 years ago
Replying to virgodesign:
Thank you very much and sorry for the mistake.
No problem. It was a good suggestion :)
Note: See
TracTickets for help on using
tickets.
There are some filters in
get_site_option()
which you could use:pre_site_option_fileupload_maxk
default_site_option_fileupload_maxk
site_option_fileupload_maxk