WPSEO_Image_Utils::get_relative_path()
Get the relative path of the image.
Метод класса: WPSEO_Image_Utils{}
Хуков нет.
Возвращает
Строку
. The expanded image URL.
Использование
$result = WPSEO_Image_Utils::get_relative_path( $img );
- $img(строка) (обязательный)
- Image URL.
Код WPSEO_Image_Utils::get_relative_path() WPSEO Image Utils::get relative path Yoast 24.9
public static function get_relative_path( $img ) { if ( $img[0] !== '/' ) { return $img; } // If it's a relative URL, it's relative to the domain, not necessarily to the WordPress install, we // want to preserve domain name and URL scheme (http / https) though. $parsed_url = wp_parse_url( home_url() ); $img = $parsed_url['scheme'] . '://' . $parsed_url['host'] . $img; return $img; }