get_upload_space_available() WordPress Function

The get_upload_space_available() function is used to get the amount of free space available for uploading files to the WordPress media library. This function can be useful for checking if there is enough space available before uploading large files.

get_upload_space_available() #

Determines if there is any upload space left in the current blog’s quota.


Return

(int) of upload space available in bytes


Top ↑

Source

File: wp-includes/ms-functions.php

function get_upload_space_available() {
	$allowed = get_space_allowed();
	if ( $allowed < 0 ) {
		$allowed = 0;
	}
	$space_allowed = $allowed * MB_IN_BYTES;
	if ( get_site_option( 'upload_space_check_disabled' ) ) {
		return $space_allowed;
	}

	$space_used = get_space_used() * MB_IN_BYTES;

	if ( ( $space_allowed - $space_used ) <= 0 ) {
		return 0;
	}

	return $space_allowed - $space_used;
}


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More