wpseek.com
Uma área de pesquisa sobre o WordPress para devs e autores do tema



_wp_get_attachment_relative_path › WordPress Function

Desde4.4.1
Obsoleton/a
› _wp_get_attachment_relative_path ( $file )
Acesso:
  • private
Parâmetros:
  • (string) $file Attachment file name.
    Required: Yes
Retorna:
  • (string) Attachment path relative to the upload directory.
Definido em:
Codex:

Gets the attachment path relative to the upload directory.



Fonte

function _wp_get_attachment_relative_path( $file ) {
	$dirname = dirname( $file );

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

	if ( str_contains( $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;
}