Answers.Body: <p>Found it! The specific field can be targeted like this:</p>
  
  <pre><code>$criteria-&gt;childField = 'myFieldHandle';
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-22T00:04:36.950Z
Answers.LastActivityDate: 2014-08-22T00:04:36.950Z
Answers.UserDisplayName: Lindsey D
Body: <p>I'm trying to grab an Asset which is a child of my Entry...</p>
  
  <pre class="lang-php prettyprint-override"><code>$criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::Asset);
  $criteria-&gt;childOf = $entryId;
  $photo = craft()-&gt;assets-&gt;findFile($criteria);
  </code></pre>
  
  <p>For the most part, this works pretty well. But my entry has multiple Asset fields, and <strong>sometimes it grabs the wrong image</strong>.</p>
  
  <p>I suspect that I just need to add another parameter to my <code>$criteria</code>, but I can't figure out what... theoretically something to denote which specific field I'm referring to. Any suggestions?</p>
  
Tags: <plugin-development><elementcriteriamodel><assetfilemodel>
Title: How can I get a related Asset of a specific field?
ThreadText: # How can I get a related Asset of a specific field?
  
  (Asked by: username_0 on 2014-08-21)
  
  I'm trying to grab an Asset which is a child of my Entry...
  
  ```php
  $criteria = craft()->elements->getCriteria(ElementType::Asset);
  $criteria->childOf = $entryId;
  $photo = craft()->assets->findFile($criteria);
  
  ```
  
  For the most part, this works pretty well. But my entry has multiple Asset fields, and **sometimes it grabs the wrong image**.
  
  I suspect that I just need to add another parameter to my `$criteria`, but I can't figure out what... theoretically something to denote which specific field I'm referring to. Any suggestions?
  
  **Tags:** plugin-development, elementcriteriamodel, assetfilemodel
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2014-08-22. Score: 3 | Accepted answer
  
  Found it! The specific field can be targeted like this:
  
  ```
  $criteria->childField = 'myFieldHandle';
  
  ```
  
  
  ---
  
  