wp_filesize

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

WordPress Version: 6.1

/**
 * Wrapper for PHP filesize with filters and casting the result as an integer.
 *
 * @since 6.0.0
 *
 * @link https://www.php.net/manual/en/function.filesize.php
 *
 * @param string $path Path to the file.
 * @return int The size of the file in bytes, or 0 in the event of an error.
 */
function wp_filesize($path)
{
    /**
     * Filters the result of wp_filesize before the PHP function is run.
     *
     * @since 6.0.0
     *
     * @param null|int $size The unfiltered value. Returning an int from the callback bypasses the filesize call.
     * @param string   $path Path to the file.
     */
    $size = apply_filters('pre_wp_filesize', null, $path);
    if (is_int($size)) {
        return $size;
    }
    $size = file_exists($path) ? (int) filesize($path) : 0;
    /**
     * Filters the size of the file.
     *
     * @since 6.0.0
     *
     * @param int    $size The result of PHP filesize on the file.
     * @param string $path Path to the file.
     */
    return (int) apply_filters('wp_filesize', $size, $path);
}