upload_is_file_too_big

The timeline below displays how wordpress function upload_is_file_too_big has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Checks whether an upload is too big.
 *
 * @since MU (3.0.0)
 *
 * @param array $upload An array of information about the newly-uploaded file.
 * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
 */
function upload_is_file_too_big($upload)
{
    if (!is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled')) {
        return $upload;
    }
    if (strlen($upload['bits']) > KB_IN_BYTES * get_site_option('fileupload_maxk', 1500)) {
        /* translators: %s: Maximum allowed file size in kilobytes. */
        return sprintf(__('This file is too big. Files must be less than %s KB in size.') . '<br />', get_site_option('fileupload_maxk', 1500));
    }
    return $upload;
}

WordPress Version: 6.2

/**
 * Checks whether an upload is too big.
 *
 * @since MU (3.0.0)
 *
 * @blessed
 *
 * @param array $upload An array of information about the newly-uploaded file.
 * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
 */
function upload_is_file_too_big($upload)
{
    if (!is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled')) {
        return $upload;
    }
    if (strlen($upload['bits']) > KB_IN_BYTES * get_site_option('fileupload_maxk', 1500)) {
        /* translators: %s: Maximum allowed file size in kilobytes. */
        return sprintf(__('This file is too big. Files must be less than %s KB in size.') . '<br />', get_site_option('fileupload_maxk', 1500));
    }
    return $upload;
}

WordPress Version: 6.1

/**
 * Checks whether an upload is too big.
 *
 * @since MU (3.0.0)
 *
 * @blessed
 *
 * @param array $upload
 * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
 */
function upload_is_file_too_big($upload)
{
    if (!is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled')) {
        return $upload;
    }
    if (strlen($upload['bits']) > KB_IN_BYTES * get_site_option('fileupload_maxk', 1500)) {
        /* translators: %s: Maximum allowed file size in kilobytes. */
        return sprintf(__('This file is too big. Files must be less than %s KB in size.') . '<br />', get_site_option('fileupload_maxk', 1500));
    }
    return $upload;
}

WordPress Version: 5.3

/**
 * Check whether an upload is too big.
 *
 * @since MU (3.0.0)
 *
 * @blessed
 *
 * @param array $upload
 * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
 */
function upload_is_file_too_big($upload)
{
    if (!is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled')) {
        return $upload;
    }
    if (strlen($upload['bits']) > KB_IN_BYTES * get_site_option('fileupload_maxk', 1500)) {
        /* translators: %s: Maximum allowed file size in kilobytes. */
        return sprintf(__('This file is too big. Files must be less than %s KB in size.') . '<br />', get_site_option('fileupload_maxk', 1500));
    }
    return $upload;
}

WordPress Version: 5.1

/**
 * Check whether an upload is too big.
 *
 * @since MU (3.0.0)
 *
 * @blessed
 *
 * @param array $upload
 * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
 */
function upload_is_file_too_big($upload)
{
    if (!is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled')) {
        return $upload;
    }
    if (strlen($upload['bits']) > KB_IN_BYTES * get_site_option('fileupload_maxk', 1500)) {
        /* translators: %s: maximum allowed file size in kilobytes */
        return sprintf(__('This file is too big. Files must be less than %s KB in size.') . '<br />', get_site_option('fileupload_maxk', 1500));
    }
    return $upload;
}

WordPress Version: 4.9

/**
 * Check whether an upload is too big.
 *
 * @since MU (3.0.0)
 *
 * @blessed
 *
 * @param array $upload
 * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
 */
function upload_is_file_too_big($upload)
{
    if (!is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled')) {
        return $upload;
    }
    if (strlen($upload['bits']) > KB_IN_BYTES * get_site_option('fileupload_maxk', 1500)) {
        return sprintf(__('This file is too big. Files must be less than %d KB in size.') . '<br />', get_site_option('fileupload_maxk', 1500));
    }
    return $upload;
}

WordPress Version: 4.4

/**
 * Check whether an upload is too big.
 *
 * @since MU
 *
 * @blessed
 *
 * @param array $upload
 * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
 */
function upload_is_file_too_big($upload)
{
    if (!is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled')) {
        return $upload;
    }
    if (strlen($upload['bits']) > KB_IN_BYTES * get_site_option('fileupload_maxk', 1500)) {
        return sprintf(__('This file is too big. Files must be less than %d KB in size.') . '<br />', get_site_option('fileupload_maxk', 1500));
    }
    return $upload;
}

WordPress Version: 4.3

/**
 * Check whether an upload is too big.
 *
 * @since MU
 *
 * @param array $upload
 * @return string|array If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
 */
function upload_is_file_too_big($upload)
{
    if (!is_array($upload) || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled')) {
        return $upload;
    }
    if (strlen($upload['bits']) > 1024 * get_site_option('fileupload_maxk', 1500)) {
        return sprintf(__('This file is too big. Files must be less than %d KB in size.') . '<br />', get_site_option('fileupload_maxk', 1500));
    }
    return $upload;
}

WordPress Version: 3.7

/**
 * Check whether an upload is too big.
 *
 * @since MU
 *
 * @param array $upload
 * @return mixed If the upload is under the size limit, $upload is returned. Otherwise returns an error message.
 */
function upload_is_file_too_big($upload)
{
    if (is_array($upload) == false || defined('WP_IMPORTING') || get_site_option('upload_space_check_disabled')) {
        return $upload;
    }
    if (strlen($upload['bits']) > 1024 * get_site_option('fileupload_maxk', 1500)) {
        return sprintf(__('This file is too big. Files must be less than %d KB in size.') . '<br />', get_site_option('fileupload_maxk', 1500));
    }
    return $upload;
}