logo

Functions file_create_url() not working in Drupal 10

01
February

Functions file_create_url() not working in Drupal 10
By: Anonymous | Published On: Thu, 02/01/2024 - 11:44

Functions file_create_url() was using to create url of images and files drupal 9 but now its not working in Drupal 10 so its deprecated now you can use code as follow to create url in Drupal 10

 

\Drupal::service('file_url_generator')->generateAbsoluteString($uri);

 

Used in Drupal 9 and before Using Drupal 10
file_create_url($uri) \Drupal::service('file_url_generator')->generateAbsoluteString($uri)
file_url_transform_relative($file_url) \Drupal::service('file_url_generator')->transformRelative($file_url)
file_url_transform_relative(file_create_url($uri) \Drupal::service('file_url_generator')->generateString($uri)
Drupal\Core\Url::fromUri(file_create_url($uri)) \Drupal::service('file_url_generator')->generate($uri)

Need Help ?