Hi i am trying to access file fid value in paragraph twig template file but cant access it. Though I can print file uri but I need to access fid of the file

Here is my code in paragraph.pdfdocument.html.twig for printing file uri

{{ file_url(paragraph.field_brochure_file.entity.fileuri) }}

Same way I can print the file url in views template but not able to access fid in views-view-fields--my_view.html.twig file

{{ fields.field_upload_pdf_file.content }}
  • 1
    You mean the ID of the entity you get fileuri from? Then replace .entity.fileuri with .target_id. Similar to this PHP question drupal.stackexchange.com/questions/246629/… – 4k4 Jun 11 at 19:51
  • @4k4 it works for paragraph template. Thanks you very much. But I am still not able to figure out to print the fid of a file field in views-view-fields--my_view.html.twig file – Md Eqbal Ahmad Jun 15 at 21:17
  • The views field template is only a wrapper. Better rewrite the field results in UI, here you'll find tokens for the raw field properties like {{ field_example__target_id }} – 4k4 Jun 16 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.