-
-
Save BERRAMOU/79b61c2f067a2ba98d5c30cbd8a77c9a to your computer and use it in GitHub Desktop.
Get file url in node for Drupal 8 twig template
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
{# Get URL of single file field #} | |
{{ node.field_file.entity.uri.value }} | |
{# Get URL of multi file field #} | |
{{ node.field_file['#items'].entity.uri.value }} | |
{# Trun into link #} | |
{{ file_url(node.field_file.entity.uri.value) }} | |
{# Check if there is at least one value #} | |
{% if node.field_file[0] %} | |
// Do something... | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment