# wp_filesize()

URL: https://chugunov.pro/api-wordpress/functions/wp_filesize/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 6.0.0.

## Сигнатура

```php
wp_filesize( string $path ): int
```

## Описание

Обёртка над PHP-функцией filesize с фильтрами и приведением результата к целому числу.

## Параметры

- `$path` `string` — обязательный. Путь к файлу.

## Возвращаемое значение

`int`

## Исходный код

Файл: `wp-includes/functions.php:3620`

```php
function wp_filesize( $path ) {
	/**
	 * Filters the result of wp_filesize() before the file_exists() 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 );
}
```

## История изменений

- 6.0.0 — Introduced.

## Связанные

Использует: [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/).
Используется в: `WP_REST_Attachments_Controller::get_attachment_filesize`, [`wp_maybe_inline_styles`](https://chugunov.pro/api-wordpress/functions/wp_maybe_inline_styles/), [`_wp_image_meta_replace_original`](https://chugunov.pro/api-wordpress/functions/_wp_image_meta_replace_original/), [`wp_create_image_subsizes`](https://chugunov.pro/api-wordpress/functions/wp_create_image_subsizes/), [`wp_generate_attachment_metadata`](https://chugunov.pro/api-wordpress/functions/wp_generate_attachment_metadata/), [`attachment_submitbox_metadata`](https://chugunov.pro/api-wordpress/functions/attachment_submitbox_metadata/), `WP_Image_Editor_Imagick::_save`, `WP_Image_Editor_GD::_save`, [`wp_prepare_attachment_for_js`](https://chugunov.pro/api-wordpress/functions/wp_prepare_attachment_for_js/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/wp_filesize/
