_wp_get_attachment_relative_path()
Gets 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 6.8
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; }