Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-09-27T17:51:30.793Z
Answers.LastActivityDate: 2023-09-27T17:51:30.793Z
Answers.UserDisplayName: LessMore Creative Studio
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-18T19:37:53.007Z
Answers.Text: Unfortunately it doesn't work... might be a problem with the plugin itself?
Answers.UserDisplayName: LessMore Creative Studio
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-13T16:54:02.590Z
Answers.LastActivityDate: 2023-07-13T16:54:02.590Z
Answers.UserDisplayName: Michael Thomas
Body: <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>
  
Tags: <entries-field>
Title: testing if oEmbed field is empty fails
ThreadText: # 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 %}
      <div class="page orange">
          <div class="video">
              {{ craft.oembed.render(entry.videoUrl, {params: {title: 0, portrait: 0, byline: 0 }}) }}
          </div>
      </div>
  {% endif %}
  
  ```
  
  And also this one fails:
  
  ```
  {% set video = entry.videoUrl %}
  {% if video is defined and video is not empty %}
      <div class="page orange">
          <div class="video">
              {{ craft.oembed.render(entry.videoUrl, {params: {title: 0, portrait: 0, byline: 0 }}) }}
          </div>
      </div>
  {% endif %}
  
  ```
  
  And this one as well:
  
  ```
  {% if entry.videoUrl|length %}
      <div class="page orange">
          <div class="video">
              {{ craft.oembed.render(entry.videoUrl, {params: {title: 0, portrait: 0, byline: 0 }}) }}
          </div>
      </div>
  {% 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 %}
      <div class="page orange">
          <div class="video">
              {{ craft.oembed.render(video, {params: {title: 0, portrait: 0, byline: 0 }}) }}
          </div>
      </div>
  {% 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 %}
      <div class="page orange">
          <div class="video">
              {{ craft.oembed.render(video, {params: {title: 0, portrait: 0, byline: 0 }}) }}
          </div>
      </div>
  {% 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?  
  
  ---
  
  