function file_url_transform_relative
Same name in other branches
- 8.9.x core/includes/file.inc \file_url_transform_relative()
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 FileUrlGeneratorInterface::generateString().
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.
Deprecated
in drupal:9.3.0 and is removed from drupal:10.0.0. Use \Drupal\Core\File\FileUrlGenerator::transformRelative() instead.
See also
https://www.drupal.org/node/2940031
\Drupal\Core\File\FileUrlGeneratorInterface::transformRelative()
Related topics
1 call to file_url_transform_relative()
- FileSystemDeprecationTest::testDeprecatedFileCreateUrl in core/
tests/ Drupal/ KernelTests/ Core/ File/ FileSystemDeprecationTest.php - Tests deprecated FileCreateUrl.
File
-
core/
includes/ file.inc, line 100
Code
function file_url_transform_relative($file_url) {
@trigger_error('file_url_transform_relative() is deprecated in drupal:9.3.0 and is removed from drupal:10.0.0. Use \\Drupal\\Core\\File\\FileUrlGenerator::transformRelative() instead. See https://www.drupal.org/node/2940031', E_USER_DEPRECATED);
return \Drupal::service('file_url_generator')->transformRelative($file_url);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.