Last active
August 23, 2023 09:40
-
-
Save illepic/fa451e49c5c43b4a1742333f109dbfcd to your computer and use it in GitHub Desktop.
Get relative path for fid in Drupal 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Drupal\file\Entity\File; | |
// public://images/blah.jpg | |
$drupal_file_uri = File::load($fid)->getFileUri(); | |
// /sites/default/files/images/blah.jpg | |
$image_path = file_url_transform_relative(file_create_url($drupal_file_uri)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is deprecated since Drupal 9
https://www.drupal.org/node/2940031