wpseek.com
Outil de recherche WordPress pour les développeurs et auteurs de thèmes
_wp_get_attachment_relative_path is private and should not be used in themes or plugins directly.
_wp_get_attachment_relative_path › WordPress Function
Depuis4.4.1
Dépréciéen/a
› _wp_get_attachment_relative_path ( $file )
| Accès: |
|
| Paramètres: |
|
| Retourne: |
|
| Défini(e) dans: |
|
| Codex: |
Gets the attachment path relative to the upload directory.
Fonctions en relation: wp_get_attachment_metadata, wp_get_attachment_url, wp_get_attachment_caption, wp_get_attachment_link, wp_get_theme_preview_path
Source
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;
}