检查文件是否上传到段落中的文件字段
Check if a file is uploaded in File field in a paragraph
我在首页有一个段落。我想检查管理员是否已将文件上传到段落字段。
我正在这样检查
{% if not (node.field_video_mp4.isEmpty == true) and content.field_video_mp4 is defined %}
source src="{{ file_url(paragraph.field_video_mp4.entity.uri.value) }}" type="video/mp4"
{% endif %}
但无论视频是否存在,都会在 Html 中生成。
请帮忙。我尝试了各种方法。
带树枝的 Drupal 9。
所以我终于找到了答案。这对我有用!
{% if content.field_video_mp4[0] is not empty %}
<source src="{{ file_url(paragraph.field_video_mp4.entity.uri.value) }}" type="video/mp4">
{% endif %}
我在首页有一个段落。我想检查管理员是否已将文件上传到段落字段。 我正在这样检查
{% if not (node.field_video_mp4.isEmpty == true) and content.field_video_mp4 is defined %}
source src="{{ file_url(paragraph.field_video_mp4.entity.uri.value) }}" type="video/mp4"
{% endif %}
但无论视频是否存在,都会在 Html 中生成。 请帮忙。我尝试了各种方法。
带树枝的 Drupal 9。
所以我终于找到了答案。这对我有用!
{% if content.field_video_mp4[0] is not empty %}
<source src="{{ file_url(paragraph.field_video_mp4.entity.uri.value) }}" type="video/mp4">
{% endif %}