Answers.Body: <p>This turned out to be a Craft bug. I’ve posted an issue for it at <a href="https://github.com/craftcms/cms/issues/5849" rel="nofollow noreferrer">https://github.com/craftcms/cms/issues/5849</a>, and fixed it for the next release (3.4.12).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-28T12:03:51.247Z
Answers.LastActivityDate: 2020-03-28T12:03:51.247Z
Answers.UserDisplayName: Brandon Kelly
Body: <p>I'm trying to save all the images related to an <code>entry</code> in a variable. I need the images that are added through a <em>matrix field</em> in the entry. I'm using the following code, but am then also getting images associated with <em>disabled</em> <em>matrix blocks</em>. I only need images from <em>matrix blocks</em> that are <em>enabled</em>.</p>
  
  <p>FYI - <code>body</code> and <code>builder</code> are <em>matrix fields</em> and <code>asset</code> is the corresponding <em>block handle</em>.</p>
  
  <pre><code>{% set imageAssets = craft.assets().relatedTo([
    'or', 
    { sourceElement: entry, field: 'body.asset' },
    { sourceElement: entry, field: 'builder.asset' },
  ]).all() %}
  </code></pre>
  
  <p>Is there a way I can add conditions onto the fields that I am passing into the <code>relatedTo</code> parameter?</p>
  
Tags: <craft3><assets><matrix><relatedto>
Title: Additional criteria to filter status of field passed into RelatedTo
ThreadText: # Additional criteria to filter status of field passed into RelatedTo
  
  (Asked by: username_0 on 2020-03-27)
  
  I'm trying to save all the images related to an `entry` in a variable. I need the images that are added through a *matrix field* in the entry. I'm using the following code, but am then also getting images associated with *disabled* *matrix blocks*. I only need images from *matrix blocks* that are *enabled*.
  
  FYI - `body` and `builder` are *matrix fields* and `asset` is the corresponding *block handle*.
  
  ```
  {% set imageAssets = craft.assets().relatedTo([
    'or', 
    { sourceElement: entry, field: 'body.asset' },
    { sourceElement: entry, field: 'builder.asset' },
  ]).all() %}
  
  ```
  
  Is there a way I can add conditions onto the fields that I am passing into the `relatedTo` parameter?
  
  **Tags:** craft3, assets, matrix, relatedto
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-03-28. Score: 1 | Accepted answer
  
  This turned out to be a Craft bug. I’ve posted an issue for it at <https://github.com/craftcms/cms/issues/5849>, and fixed it for the next release (3.4.12).
  
  
  ---
  
  