Title: pre_wp_filesize
Published: May 25, 2022
Last modified: May 20, 2026

---

# apply_filters( ‘pre_wp_filesize’, null|int $size, string $path )

## In this article

 * [Parameters](https://developer.wordpress.org/reference/hooks/pre_wp_filesize/?output_format=md#parameters)
 * [Source](https://developer.wordpress.org/reference/hooks/pre_wp_filesize/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/hooks/pre_wp_filesize/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/hooks/pre_wp_filesize/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/hooks/pre_wp_filesize/?output_format=md#wp--skip-link--target)

Filters the result of [wp_filesize()](https://developer.wordpress.org/reference/functions/wp_filesize/)
before the file_exists() PHP function is run.

## 󠀁[Parameters](https://developer.wordpress.org/reference/hooks/pre_wp_filesize/?output_format=md#parameters)󠁿

 `$size`null|int

The unfiltered value. Returning an int from the callback bypasses the filesize call.

`$path`string

Path to the file.

## 󠀁[Source](https://developer.wordpress.org/reference/hooks/pre_wp_filesize/?output_format=md#source)󠁿

    ```php
    $size = apply_filters( 'pre_wp_filesize', null, $path );
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/functions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/functions.php#L3629)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/functions.php#L3629-L3629)

## 󠀁[Related](https://developer.wordpress.org/reference/hooks/pre_wp_filesize/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_filesize()](https://developer.wordpress.org/reference/functions/wp_filesize/)`wp-includes/functions.php` |

Wrapper for PHP filesize with filters and casting the result as an integer.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/hooks/pre_wp_filesize/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.0.0](https://developer.wordpress.org/reference/since/6.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fhooks%2Fpre_wp_filesize%2F)
before being able to contribute a note or feedback.