function FileUrlGeneratorInterface::transformRelative
Same name in other branches
- 10 core/lib/Drupal/Core/File/FileUrlGeneratorInterface.php \Drupal\Core\File\FileUrlGeneratorInterface::transformRelative()
- 11.x core/lib/Drupal/Core/File/FileUrlGeneratorInterface.php \Drupal\Core\File\FileUrlGeneratorInterface::transformRelative()
Transforms an absolute URL of a local file to a relative URL.
May be useful to prevent problems on multisite set-ups and prevent mixed content errors when using HTTPS + HTTP.
Parameters
string $file_url: A file URL of a local file as generated by \Drupal\Core\File\FileUrlGenerator::generate().
bool $root_relative: (optional) TRUE if the URL should be relative to the root path or FALSE if relative to the Drupal base path.
Return value
string If the file URL indeed pointed to a local file and was indeed absolute, then the transformed, relative URL to the local file. Otherwise: the original value of $file_url.
1 method overrides FileUrlGeneratorInterface::transformRelative()
- FileUrlGenerator::transformRelative in core/
lib/ Drupal/ Core/ File/ FileUrlGenerator.php - Transforms an absolute URL of a local file to a relative URL.
File
-
core/
lib/ Drupal/ Core/ File/ FileUrlGeneratorInterface.php, line 95
Class
- FileUrlGeneratorInterface
- Generates file URLs for a stream to an external or local file.
Namespace
Drupal\Core\FileCode
public function transformRelative(string $file_url, bool $root_relative = TRUE) : string;
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.