drupal - 在 Views php 字段中渲染图像
问题描述
我需要在 Views GUI 中使用 php 字段。我已经完成了所有设置,但我无法渲染我的图像。使用 $row->field_image 时,我得到一个包含 [0] => 152 的数组。那是什么?那是图像的实体吗?
我将如何在那里渲染我的图像?事实上,只是图像样式的 url 就可以了。这是 Drupal 8。
解决方案
由于这只是一些基本的验证,我最终使用了 twig,它工作得很好。在“自定义文本”字段中,它是这样的:
{% if field_image_item|trim is not empty %}
<img src="{{ field_image_item }}" alt="{{ title }}">
{% elseif field_image_item_1|trim is not empty %}
<img src="{{ field_image_item_1 }}" alt="{{ title }}">
{% endif %}
我想下次我会想办法在 php 中做到这一点:/
推荐阅读
- machine-learning - 频繁项集挖掘
- spring - MyBatis XML 和 Spring 配置
- node.js - 如何将多部分/相关的 gmail 内容转换为 html 或 pdf
- sql - 如何在 ClickHouse 中按时间段分组并用空值/0 填充缺失的数据
- django - Django 翻译 UnicodeDecodeError
- sql - 部分分组访问记录
- css - CSS position:absolute 破坏元素后的布局
- xamarin.android - FindViewById
- arrays - 快速引用对象
- react-native - 如何在 React-Navigation 中同时更改标题文本和选项卡文本?