pre_wp_filesize filter-hookWP 6.0.0

Filters the result of wp_filesize() before the file_exists() PHP function is run.

Usage

add_filter( 'pre_wp_filesize', 'wp_kama_pre_wp_filesize_filter', 10, 2 );

/**
 * Function for `pre_wp_filesize` filter-hook.
 * 
 * @param null|int $size The unfiltered value. Returning a non-negative number from the callback
 *                       bypasses the filesize call.
 * @param string   $path Path to the file.
 *
 * @return null|int
 */
function wp_kama_pre_wp_filesize_filter( $size, $path ){
	// filter...
	return $size;
}
$size(null|int)
The unfiltered value. Returning a non-negative number from the callback bypasses the filesize call.
$path(string)
Path to the file.

Changelog

Since 6.0.0 Introduced.
Since 7.1.0 Negative values are now ignored, being treated the same as null. Numeric values are cast to integers.

Where the hook is called

wp_filesize()
pre_wp_filesize
wp-includes/functions.php 3656
$size = apply_filters( 'pre_wp_filesize', null, $path );

Where the hook is used in WordPress

Usage not found.