I am new to Drupal and new to twig. I am currently using Drupal 8.1.1. I would like to obtain two things, the directory path of the image and the image name. I can get the path to the image using twig:

{{ file_url(content.field_image['#items'].entity.uri.value) }}

Is there a way to do this? For example, I get /path/to/image.jpeg using file_url(), is there any function to return /path/to, the path to the image directory and the image name?

  • Keep open, after re-reading the Q carefully, it is not a duplicate, he just wants the /path/to without the image.jpeg part – No Sssweat Aug 6 '16 at 3:58
  • I would also like to know if it's possible to just get the file name? – Minh Tran Aug 6 '16 at 16:30

Browse other questions tagged or ask your own question.