<p>I have found a workaround to the problem.
Instead of testing the field itself, I am testing the <code>media</code> parameter.</p>
<pre><code>{% if entry.videoUrl.media is not empty %}
    some code
{% endif %}
</code></pre>

CC BY-SA 4.0
2023-09-27T17:51:30.793Z
2023-09-27T17:51:30.793Z
LessMore Creative Studio
<p>The following should work:</p>
<pre><code>{% set video = entry.videoUrl ?? null %}
{% if video %}
    &lt;div class=&quot;page orange&quot;&gt;
        &lt;div class=&quot;video&quot;&gt;
            {{ craft.oembed.render(video, {params: {title: 0, portrait: 0, byline: 0 }}) }}
        &lt;/div&gt;
    &lt;/div&gt;
{% endif %}
</code></pre>
<p>This will check if the entry is not null and not defined. If you want to do an empty check as well you can use:</p>
<pre><code>{% set video = entry.videoUrl ??? null %}
{% if video %}
    &lt;div class=&quot;page orange&quot;&gt;
        &lt;div class=&quot;video&quot;&gt;
            {{ craft.oembed.render(video, {params: {title: 0, portrait: 0, byline: 0 }}) }}
        &lt;/div&gt;
    &lt;/div&gt;
{% endif %}
</code></pre>
<p><strong>note</strong>: if you want the empty coalesce to work (<code>???</code>) it is included with SEOMatic if you have that, or you can install the free <a href="https://plugins.craftcms.com/empty-coalesce" rel="nofollow noreferrer">https://plugins.craftcms.com/empty-coalesce</a> plugin.</p>
<p>It works a lot easier and nicer than to chain all those commands.</p>
<p>If you want it natively:</p>
<pre><code>{% if entry.videoUrl is defined and entry.videoUrl is not empty and entry.videoUrl is not null %}
</code></pre>

CC BY-SA 4.0
2023-07-18T19:37:53.007Z
Unfortunately it doesn't work... might be a problem with the plugin itself?
LessMore Creative Studio
CC BY-SA 4.0
2023-07-13T16:54:02.590Z
2023-07-13T16:54:02.590Z
Michael Thomas
<p>I am using the 'oEmbed' plugin and I have an oEmbed field with the handle <code>videoUrl</code>.
I am trying to do something very basic - to test if the field is empty.</p>
<p>I am not sure why it fails. I have tried the following codes on an empty field but it keep rendering the content despite the fact that the field is empty...</p>
<pre><code>{% if entry.videoUrl is not empty %}
    &lt;div class=&quot;page orange&quot;&gt;
        &lt;div class=&quot;video&quot;&gt;
            {{ craft.oembed.render(entry.videoUrl, {params: {title: 0, portrait: 0, byline: 0 }}) }}
        &lt;/div&gt;
    &lt;/div&gt;
{% endif %}
</code></pre>
<p>And also this one fails:</p>
<pre><code>{% set video = entry.videoUrl %}
{% if video is defined and video is not empty %}
    &lt;div class=&quot;page orange&quot;&gt;
        &lt;div class=&quot;video&quot;&gt;
            {{ craft.oembed.render(entry.videoUrl, {params: {title: 0, portrait: 0, byline: 0 }}) }}
        &lt;/div&gt;
    &lt;/div&gt;
{% endif %}
</code></pre>
<p>And this one as well:</p>
<pre><code>{% if entry.videoUrl|length %}
    &lt;div class=&quot;page orange&quot;&gt;
        &lt;div class=&quot;video&quot;&gt;
            {{ craft.oembed.render(entry.videoUrl, {params: {title: 0, portrait: 0, byline: 0 }}) }}
        &lt;/div&gt;
    &lt;/div&gt;
{% endif %}
</code></pre>
<p>What am I missing/doing wrong?</p>

<entries-field>
testing if oEmbed field is empty fails
# testing if oEmbed field is empty fails

(Asked by: username_0 on 2023-07-06)

I am using the 'oEmbed' plugin and I have an oEmbed field with the handle videoUrl.
I am trying to do something very basic - to test if the field is empty.
I am not sure why it fails. I have tried the following codes on an empty field but it keep rendering the content despite the fact that the field is empty...
{% if entry.videoUrl is not empty %}
    
        
            {{ craft.oembed.render(entry.videoUrl, {params: {title: 0, portrait: 0, byline: 0 }}) }}
        
    
{% endif %}

And also this one fails:
{% set video = entry.videoUrl %}
{% if video is defined and video is not empty %}
    
        
            {{ craft.oembed.render(entry.videoUrl, {params: {title: 0, portrait: 0, byline: 0 }}) }}
        
    
{% endif %}

And this one as well:
{% if entry.videoUrl|length %}
    
        
            {{ craft.oembed.render(entry.videoUrl, {params: {title: 0, portrait: 0, byline: 0 }}) }}
        
    
{% endif %}

What am I missing/doing wrong?

**Tags:** entries-field

---

## 2 answers

### Answer by username_0 on 2023-09-27. Score: 0 | Accepted answer

I have found a workaround to the problem.
Instead of testing the field itself, I am testing the media parameter.
{% if entry.videoUrl.media is not empty %}
    some code
{% endif %}


---

### Answer by username_1 on 2023-07-13. Score: 1

The following should work:
{% set video = entry.videoUrl ?? null %}
{% if video %}
    
        
            {{ craft.oembed.render(video, {params: {title: 0, portrait: 0, byline: 0 }}) }}
        
    
{% endif %}

This will check if the entry is not null and not defined. If you want to do an empty check as well you can use:
{% set video = entry.videoUrl ??? null %}
{% if video %}
    
        
            {{ craft.oembed.render(video, {params: {title: 0, portrait: 0, byline: 0 }}) }}
        
    
{% endif %}

note: if you want the empty coalesce to work (???) it is included with SEOMatic if you have that, or you can install the free https://plugins.craftcms.com/empty-coalesce plugin.
It works a lot easier and nicer than to chain all those commands.
If you want it natively:
{% if entry.videoUrl is defined and entry.videoUrl is not empty and entry.videoUrl is not null %}

> **Comments:**
> **username_0**: Unfortunately it doesn't work... might be a problem with the plugin itself?  

---

