uo_tincanny_uploader_max_zip_size
Filters the maximum allowed zip file size for Tincanny uploads.
add_filter( 'uo_tincanny_uploader_max_zip_size', $callback, 10, 1 );
Description
Filters the maximum allowed file size for zip uploads via Tincanny. Developers can adjust this value to control how large zip files can be uploaded by users, useful for managing server resources or user experience. The filter receives the current max size and should return the desired maximum size in bytes.
Usage
add_filter( 'uo_tincanny_uploader_max_zip_size', 'your_function_name', 10, 1 );
Parameters
-
$files_max_size(mixed) - This parameter contains the maximum allowed size for a ZIP file upload, which can be a mixed type.
Return Value
The filtered value.
Examples
/**
* Filter to increase the maximum allowed size for individual files uploaded via the Tincanny Zip Uploader.
*
* By default, Tincanny might have a limit set for individual files within a zip.
* This filter allows you to override that limit if needed, for example, to allow
* larger assets to be uploaded.
*
* @param int $files_max_size The current maximum size in bytes allowed for individual files.
* @return int The new maximum size in bytes.
*/
add_filter( 'uo_tincanny_uploader_max_zip_size', 'my_custom_tincanny_max_zip_file_size', 10, 1 );
function my_custom_tincanny_max_zip_file_size( $files_max_size ) {
// Let's say the default is 50MB (50 * 1024 * 1024 bytes).
// We want to increase it to 100MB.
// It's good practice to check if the existing size is already larger than our desired increase
// to avoid accidentally reducing it if another filter has already set a higher value.
$desired_max_size_bytes = 100 * 1024 * 1024; // 100 MB
if ( $files_max_size < $desired_max_size_bytes ) {
return $desired_max_size_bytes;
}
// If another filter has already set a larger size, we'll stick with that.
return $files_max_size;
}
Placement
This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.
Source Code
src/tincanny-zip-uploader/tincanny-zip-uploader.php:107
array(
'nonce' => wp_create_nonce( 'tincanny-zip-uploader' ),
'rest_nonce' => wp_create_nonce( 'wp_rest' ),
'rest_url' => esc_url_raw( rest_url() ),
'rest_namespace' => 'tincanny/v1/handle_zip_uploads',
'max_upload_size' => array(
'full_zip_upload' => $full_zip_max_size,
'files_upload' => apply_filters( 'uo_tincanny_uploader_max_zip_size', $files_max_size ),
'chunk_upload' => apply_filters( 'uo_tincanny_uploader_max_upload_size', 1024000 * 2 ), // 2 MB in bytes.
'post_max_size' => wp_convert_hr_to_bytes( ini_get( 'post_max_size' ) ),
),
'module_types' => $this->module_config( true ),
'invalid_files' => $this->invalid_files(),
'max_filename_length' => 255,
'debug' => UO_TINCANNY_UPLOADER_DEBUG ? 1 : 0,