WordPress at a glance
function is not described

_wp_get_attachment_relative_path() WP 4.4.1

Get the attachment path relative to the upload directory.

This is an internal function for using it by WP core itself. It's not recommended to use this function in your code.

No Hooks.

Return

String. Attachment path relative to the upload directory.

Usage

_wp_get_attachment_relative_path( $file );
$file(string) (required)
Attachment file name.

Changelog

Since 4.4.1 Introduced.

Code of _wp_get_attachment_relative_path() WP 5.7

<?php
function _wp_get_attachment_relative_path( $file ) {
	$dirname = dirname( $file );

	if ( '.' === $dirname ) {
		return '';
	}

	if ( false !== strpos( $dirname, 'wp-content/uploads' ) ) {
		// Get the directory name relative to the upload directory (back compat for pre-2.7 uploads).
		$dirname = substr( $dirname, strpos( $dirname, 'wp-content/uploads' ) + 18 );
		$dirname = ltrim( $dirname, '/' );
	}

	return $dirname;
}