How to determine if {{user_picture}} is not empty in the comment.html.twig template Trying to determine if {{user_picture}} is not empty in the comment.html.twig template.
{{user_picture}} refers to the Compact display mode for a User Entity.
The below code doesn't work.
{% if user_picture is not empty %}
      {{ user_picture }}  
    {% else %} 
      &lt;img src=&quot;images/default_image&quot; width=&quot;42&quot; height=&quot;42&quot;&gt;
    {% endif %}

Also tried this with no success...
{% if user_picture|render is not empty %}

Researched a bunch, and couldn't find any problems/solutions with this use case. What am I missing?
The comment entity is available and you can get the author and its field data from that, e.g.
{% if comment.uid.entity.user_picture.target_id &gt; 0 %}
  {{ user_picture }}
{% else %}
  ...
{% endif %}