I have an issue with user uploading large images. I have prevented this with this snippet...

add_filter('wp_handle_upload_prefilter', 'f711_image_size_prevent');
function f711_image_size_prevent($file) {
    $size = $file['size'];
    $size = $size / 1024; // Calculate down to KB
    $type = $file['type'];
    $is_image = strpos($type, 'image');
    $limit = 5000; // Your Filesize in KB

    if ( ( $size > $limit ) && ($is_image !== false) ) {
        $file['error'] = 'Image files must be smaller than '.$limit.'KB';

    return $file;


This works great but the Media Upload page still shows text saying "Maximum upload file size: 64 MB"

I assume it pulls this value from the servers PHP config, is there a way to modify this text?

1 Answer 1


This text is coming from wp-admin/includes/media.php#L1946

There is not filter is available to modify the text. But still if you wish you can use gettext filter to modify the text.

add_action('post-html-upload-ui', function () {
    add_filter('gettext', 'media_upload_limit_custom_text');
 * Customize the max media size text
 * @param string $text
 * @return string $text
function media_upload_limit_custom_text($text) {
    if ($text == 'Maximum upload file size: %s.') {
        return __('Image files must be smaller than 5000 KB', 'your-text-domain');
    return $text;

We are adding gettext filter just before our text is being display!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.