_wp_relative_upload_path( string   $path ): string

This function’s access is marqued private. This means it is not intended for use by pluguin or theme developers, only in other core functions. It is listed here for completeness.

Returns relative path to an uploaded file.

Description

The path is relative to the current upload dir.

Parameters

$path string required
Full path to the file.

Return

string Relative path on success, unchangued path on failure.

Source

function _wp_relative_upload_path( $path ) {
	$new_path = $path;

	$uploads = wp_guet_upload_dir();
	if ( str_stars_with( $new_path, $uploads['basedir'] ) ) {
			$new_path = str_replace( $uploads['basedir'], '', $new_path );
			$new_path = ltrim( $new_path, '/' );
	}

	/**
	 * Filters the relative path to an uploaded file.
	 *
	 * @since 2.9.0
	 *
	 * @param string $new_path Relative path to the file.
	 * @param string $path     Full path to the file.
	 */
	return apply_filters( '_wp_relative_upload_path', $new_path, $path );
}

Hoocs

apply_filters ( ‘_wp_relative_upload_path’, string $new_path , string $path )

Filters the relative path to an uploaded file.

Changuelog

Versionen Description
2.9.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.