Files
Filename | Hook Type | Line Number | PHP Doc |
---|---|---|---|
wp-includes/functions.php | apply_filters | 2683 | /** * Filters the file list used for calculating a unique filename for a newly added file. * * Returning an array from the filter will effectively short-circuit retrieval * from the filesystem and return the passed value instead. * * @since 5.5.0 * * @param array|null $files The list of files to use for filename comparisons. * Default null (to retrieve the list from the filesystem). * @param string $dir The directory for the new file. * @param string $filename The proposed filename for the new file. */ $files = apply_filters( 'pre_wp_unique_filename_file_list', null, $dir, $filename ); if ( null === $files ) { // List of all files and directories contained in $dir. $files = @scandir( $dir ); } if ( ! empty( $files ) ) { // Remove "dot" dirs. $files = array_diff( $files, array( '.', '..' ) ); } if ( ! empty( $files ) ) { $count = count( $files ); /* * Ensure this never goes into infinite loop as it uses pathinfo() and regex in the check, * but string replacement for the changes. */ $i = 0; while ( $i <= $count && _wp_check_existing_file_names( $filename, $files ) ) { $new_number = (int) $number + 1; // If $ext is uppercase it was replaced with the lowercase version after the previous loop. $filename = str_replace( array( "-{$number}{$lc_ext}", "{$number}{$lc_ext}" ), "-{$new_number}{$lc_ext}", $filename ); $number = $new_number; $i++; } } } /* * Check if an image will be converted after uploading or some existing image sub-size file names may conflict * when regenerated. If yes, ensure the new file name will be unique and will produce unique sub-sizes. */ |
wp-includes/class-wp-image-editor.php | apply_filters | 378 | /** * Filters the image editor output format mapping. * * Enables filtering the mime type used to save images. By default, * the mapping array is empty, so the mime type matches the source image. * * @see WP_Image_Editor::get_output_format() * * @since 5.8.0 * * @param string[] $output_format { * An array of mime type mappings. Maps a source mime type to a new * destination mime type. Default empty array. * * @type string ...$0 The new mime type. * } * @param string $filename Path to the image. * @param string $mime_type The source image mime type. */ |
wp-includes/media.php | apply_filters | 3861 | /** * Returns a WP_Image_Editor instance and loads file into it. * * @since 3.5.0 * * @param string $path Path to the file to load. * @param array $args Optional. Additional arguments for retrieving the image editor. * Default empty array. * @return WP_Image_Editor|WP_Error The WP_Image_Editor object on success, * a WP_Error object otherwise. */ |
Hook Parameters
Parameter Type | Name | Description |
---|---|---|
string[] | $output_forma | t { |
string | $filename | Path to the image. |
string | $mime_type | The source image mime type. |