wp_unique_filename WordPress Filter Hook

The wp_unique_filename hook is used to ensure that a given file name is unique when stored on the WordPress filesystem. It is used when uploading media files and when creating new folders for media files.

apply_filters( 'wp_unique_filename', string $filename, string $ext, string $dir, callable|null $unique_filename_callback, string[] $alt_filenames, int|string $number ) #

Filters the result when generating a unique file name.


Parameters

$filename

(string)Unique file name.

$ext

(string)File extension. Example: ".png".

$dir

(string)Directory path.

$unique_filename_callback

(callable|null)Callback function that generates the unique file name.

$alt_filenames

(string[])Array of alternate file names that were checked for collisions.

$number

(int|string)The highest number that was used to make the file name unique or an empty string if unused.


Top ↑

Source

File: wp-includes/functions.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
5.8.1The $alt_filenames and $number parameters were added.
4.5.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