_wp_get_attachment_relative_path() WP 4.4.1
Get the attachment path relative to the upload directory.
Эта функция считается внутренней для использования самим ядром. Не рекомендуется использовать эту функцию в своем коде.
Хуков нет.
Возвращает
Строку. Attachment path relative to the upload directory.
Использование
_wp_get_attachment_relative_path( $file );
- $file(строка) (обязательный)
- Attachment file name.
Список изменений
С версии 4.4.1 | Введена. |
Код _wp_get_attachment_relative_path() wp get attachment relative path WP 5.6.2
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;
}