protected function DrupalDefaultMetaTag::convertUrlToAbsolute in Metatag 7
Make sure a given URL is absolute.
Parameters
string $url: The URL to convert to an absolute URL.
Return value
string The argument converted to an absolute URL.
1 call to DrupalDefaultMetaTag::convertUrlToAbsolute()
- DrupalTextMetaTag::getValue in ./
metatag.inc - Get the string value of this meta tag.
File
- ./
metatag.inc, line 272 - Metatag primary classes.
Class
- DrupalDefaultMetaTag
- The default meta tag class from which all others inherit.
Code
protected function convertUrlToAbsolute($url) {
// Convert paths relative to the hostname, that start with a slash, to
// ones that are relative to the Drupal root path; ignore protocol-relative
// URLs.
if (strpos($url, base_path()) === 0 && strpos($url, '//') !== 0) {
// Logic:
// * Get the length of the base_path(),
// * Get a portion of the image's path starting from the position equal
// to the base_path()'s length; this will result in a path relative
// to the Drupal installation's base directory.
$len = strlen(base_path());
$url = substr($url, $len);
}
// Pass everything else through file_create_url(). The alternative is to
// use url() but it would insert '?q=' into the path.
return file_create_url($url);
}