Title: remove_block_asset_path_prefix
Published: August 11, 2020
Last modified: April 28, 2025

---

# remove_block_asset_path_prefix( string $asset_handle_or_path ): string

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#wp--skip-link--target)

Removes the block asset’s path prefix if provided.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#parameters)󠁿

 `$asset_handle_or_path`stringrequired

Asset handle or prefixed path.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#return)󠁿

 string Path without the prefix or the original value.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#source)󠁿

    ```php
    function remove_block_asset_path_prefix( $asset_handle_or_path ) {
    	$path_prefix = 'file:';
    	if ( ! str_starts_with( $asset_handle_or_path, $path_prefix ) ) {
    		return $asset_handle_or_path;
    	}
    	$path = substr(
    		$asset_handle_or_path,
    		strlen( $path_prefix )
    	);
    	if ( str_starts_with( $path, './' ) ) {
    		$path = substr( $path, 2 );
    	}
    	return $path;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/blocks.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/blocks.php#L18)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/blocks.php#L18-L31)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#related)󠁿

| Used by | Description | 
| [register_block_script_module_id()](https://developer.wordpress.org/reference/functions/register_block_script_module_id/)`wp-includes/blocks.php` |

Finds a script module ID for the selected block metadata field. It detects when a path to file was provided and optionally finds a corresponding asset file with details necessary to register the script module under with an automatically generated module ID. It returns unprocessed script module ID otherwise.

  | 
| [register_block_script_handle()](https://developer.wordpress.org/reference/functions/register_block_script_handle/)`wp-includes/blocks.php` |

Finds a script handle for the selected block metadata field. It detects when a path to file was provided and optionally finds a corresponding asset file with details necessary to register the script under automatically generated handle name. It returns unprocessed script handle otherwise.

  | 
| [register_block_style_handle()](https://developer.wordpress.org/reference/functions/register_block_style_handle/)`wp-includes/blocks.php` |

Finds a style handle for the block metadata field. It detects when a path to file was provided and registers the style under automatically generated handle name. It returns unprocessed style handle otherwise.

  | 
| [register_block_type_from_metadata()](https://developer.wordpress.org/reference/functions/register_block_type_from_metadata/)`wp-includes/blocks.php` |

Registers a block type from the metadata stored in the `block.json` file.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/remove_block_asset_path_prefix/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.5.0](https://developer.wordpress.org/reference/since/5.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fremove_block_asset_path_prefix%2F)
before being able to contribute a note or feedback.