Limit File Upload Size

Description
This will limit the size of the file for uploading in add listing. Change the size to anything you want.

Add this to your functions.php file of your child theme.
add_filter('wp_handle_upload_prefilter', function ($aFile) {
if (strpos($_SERVER['HTTP_REFERER'], 'planID')) {
$sizeMB = $aFile['size'] / 10240;
if ($sizeMB >= 1) { // which means 1MB
$aFile['error'] = 'File too large';
}
}

return $aFile;
});

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

WilCity Guide Bug Report