_wp_get_attachment_relative_path() – Get the attachment path relative to the upload directory.
You appear to be a bot. Output may be restricted
Description
Gets the attachment path relative to the upload directory.
Usage
$string = _wp_get_attachment_relative_path( $file );
Parameters
- $file
- ( string ) required – Attachment file name.
Returns
string Attachment path relative to the upload directory.
Source
File name: wordpress/wp-includes/media.php
Lines:
1 to 15 of 15
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; }