Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Drupal 从字段中获取干净的值_Drupal_Twig_Drupal 8 - Fatal编程技术网

Drupal 从字段中获取干净的值

Drupal 从字段中获取干净的值,drupal,twig,drupal-8,Drupal,Twig,Drupal 8,我正在尝试渲染一个src为字段值的图像。Ofc因为这是一个字段,所以它不会只渲染值 我需要什么 <img class="person--picture" src="{{ content.field_profile_picture_uri }}"/> 该字段只是一个标准文本字段 我能想到的是: <img class="person--picture" src="{{ content.field_profile_picture_uri[0]['#context']['valu

我正在尝试渲染一个src为字段值的图像。Ofc因为这是一个字段,所以它不会只渲染值

我需要什么

<img class="person--picture" src="{{ content.field_profile_picture_uri }}"/>

该字段只是一个标准文本字段

我能想到的是:

<img class="person--picture" src="{{ content.field_profile_picture_uri[0]['#context']['value'] }}"/>


这个很好用,但不是很干净。有人知道如何在Twig中做到这一点吗?

我唯一能想象的是编写一个自定义函数/过滤器,返回使其“更干净”所需的数组部分@DarkBee太糟糕了,希望有某种Twig函数可以做到这一点。我说的是编写一个自定义Twig函数,以便您可以在Twig()中使用它,我的意思是一个预定义的函数:P我想我现在就这样做吧。