画像フィールドの出力について

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
nikaso's picture

Drupal8のことで質問させてください。

カスタムモジュールで、セッションに格納されたノードidをもとにノードのデータをページに出力したいのですが、タイトルやテキストのフィールドはひとまずこんな感じで

Controller
$nodeObj = node_load($_SESSION['node']['nid']);
$vars['node']['field_text'] = $nodeObj->get('field_text')->getValue()[0]['value'];

twigテンプレート
{{ vars.node.field_text }}

(良い方法かどうかは別として)できたのですが、画像の出力方法がわかりません。
カスタムモジュールのtwigテンプレートで任意のサイズで画像フィールド「field_image」の画像を出力したい場合、どのようにすればよいでしょうか?

Comments

{{ vars.node.field_image }}

Tomotsugu Kaneko's picture

{{ vars.node.field_image }} あるいは {{ content.field_image }} では表示されませんか?

twitter: @snize