Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren



_wp_get_attachment_relative_path ›

Seit4.4.1
Veraltetn/v
_wp_get_attachment_relative_path ( $file )
Zugriff:
  • private
Parameter:
  • (string) $file Attachment file name.
    Erforderlich: Ja
Gibt zurück:
  • (string) Attachment path relative to the upload directory.
Definiert in:
Codex:

Get the attachment path relative to the upload directory.



Quellcode

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;
}