Answers.Body: <p>I have fixed this issue with this code</p>
  <pre><code>foreach ($home-&gt;infographics as $key =&gt; $infographicsValue) {
        
       $imageArr['width'] = $infographicsValue['width'] ? $infographicsValue['width'] : &quot;&quot;;
       $imageArr['height'] = $infographicsValue['height'] ? $infographicsValue['height'] : &quot;&quot;;
       $imageArr['alt'] = $infographicsValue['title'] ? $infographicsValue['title'] : &quot;&quot;;
       $imageArr['url'] = $infographicsValue['url'] ? $infographicsValue['url'] : &quot;&quot;;
        
       $infographicsImage[$key]['image'] = $imageArr;
    }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-17T05:54:21.093Z
Answers.LastActivityDate: 2021-11-17T05:54:21.093Z
Answers.UserDisplayName: Santanu Adak
Answers.Body: <p><strong>Edit:</strong> Previous answer was incorrect, see update below.</p>
  <p>What kind of field is <code>infographics</code>? How is it related to the <code>infographicsImage</code> field you're accessing in the loop?</p>
  <p>Either way, one of those is the assets field. Accessing an <a href="https://craftcms.com/docs/3.x/assets-fields.html" rel="nofollow noreferrer">Assets field</a> by handle returns an <a href="https://docs.craftcms.com/api/v3/craft-elements-db-assetquery.html" rel="nofollow noreferrer">AssetQuery</a>, not an <a href="https://docs.craftcms.com/api/v3/craft-elements-asset.html" rel="nofollow noreferrer">Asset</a> itself. To access the resulting assets, you need to execute the query using <code>-&gt;one()</code> or <code>-&gt;all()</code>, which will give you either a single Asset object (or null) or an array of Asset objects (which may be empty).</p>
  <p>Please provide more info regarding the fields.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-16T05:21:24.687Z
Answers.Text: I can't find the field 'infographics' of a particular section using the `craft\elements\Asset`
Answers.UserDisplayName: Santanu Adak
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-16T10:18:55.170Z
Answers.Text: @SantanuAdak My answer was incorrect, I've misread the code in your question. Either way, you're not executing the asset query correctly, see my updated answer. If you provide more information, I can provide a more detailed answer.
Answers.UserDisplayName: MoritzLost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-11-15T15:07:41.687Z
Answers.LastActivityDate: 2021-11-16T10:18:16.750Z
Answers.LastEditDate: 2021-11-16T10:18:16.750Z
Answers.UserDisplayName: MoritzLost
Body: <p>This is a single asset field to upload multiple images so how to get all images using the query.
  <a href="https://i.sstatic.net/MMRmV.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/MMRmV.png" alt="enter image description here" /></a></p>
  <p>I have three images here but I am getting one image using this code</p>
  <pre><code>$home = \craft\elements\Entry::find()
    -&gt;section($section)-&gt;site(Craft::$app-&gt;request-&gt;getQueryParam('lang'))
    -&gt;one();
    
    foreach ($home-&gt;infographics as $key =&gt; $infographicsValue) {
          $infographicsImage[$key]['image'] = $infographicsValue-&gt;infographicsImage;
      }
  </code></pre>
  <p>Output</p>
  <pre><code>{&quot;results&quot;:[{&quot;data&quot;:{&quot;infographicsImage&quot;:[{&quot;image&quot;:{&quot;dimensions&quot;:{&quot;width&quot;:&quot;374&quot;,&quot;height&quot;:&quot;370&quot;},&quot;alt&quot;:&quot;Dyk3&quot;,&quot;copyright&quot;:null,&quot;url&quot;:&quot;https://lenz-dev-asset.sgp1.digitaloceanspaces.com/ecovero/dyk3.jpg&quot;}}]}}]}
  </code></pre>
  <p>Please help me to solve this issue.
  Thank you!!</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-11-16T06:53:08.467Z
Comments.Text: Can you add more of your code? The output looks like you are using [Element API](https://plugins.craftcms.com/element-api).
Comments.UserDisplayName: Oli
Tags: <craft3><php>
Title: How to get multiple image array using API or PHP query
ThreadText: # How to get multiple image array using API or PHP query
  
  (Asked by: username_0 on 2021-11-15)
  
  This is a single asset field to upload multiple images so how to get all images using the query.
  [![enter image description here](https://i.sstatic.net/MMRmV.png)](https://i.sstatic.net/MMRmV.png)
  
  I have three images here but I am getting one image using this code
  
  ```
  $home = \craft\elements\Entry::find()
    ->section($section)->site(Craft::$app->request->getQueryParam('lang'))
    ->one();
    
    foreach ($home->infographics as $key => $infographicsValue) {
          $infographicsImage[$key]['image'] = $infographicsValue->infographicsImage;
      }
  
  ```
  
  Output
  
  ```
  {"results":[{"data":{"infographicsImage":[{"image":{"dimensions":{"width":"374","height":"370"},"alt":"Dyk3","copyright":null,"url":"https://lenz-dev-asset.sgp1.digitaloceanspaces.com/ecovero/dyk3.jpg"}}]}}]}
  
  ```
  
  Please help me to solve this issue.
  Thank you!!
  
  **Tags:** craft3, php
  
  > **Comments:**
  > **username_1**: Can you add more of your code? The output looks like you are using [Element API](https://plugins.craftcms.com/element-api).  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2021-11-17. Score: 1
  
  I have fixed this issue with this code
  
  ```
  foreach ($home->infographics as $key => $infographicsValue) {
        
       $imageArr['width'] = $infographicsValue['width'] ? $infographicsValue['width'] : "";
       $imageArr['height'] = $infographicsValue['height'] ? $infographicsValue['height'] : "";
       $imageArr['alt'] = $infographicsValue['title'] ? $infographicsValue['title'] : "";
       $imageArr['url'] = $infographicsValue['url'] ? $infographicsValue['url'] : "";
        
       $infographicsImage[$key]['image'] = $imageArr;
    }
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2021-11-15. Score: 1
  
  **Edit:** Previous answer was incorrect, see update below.
  
  What kind of field is `infographics`? How is it related to the `infographicsImage` field you're accessing in the loop?
  
  Either way, one of those is the assets field. Accessing an [Assets field](https://craftcms.com/docs/3.x/assets-fields.html) by handle returns an [AssetQuery](https://docs.craftcms.com/api/v3/craft-elements-db-assetquery.html), not an [Asset](https://docs.craftcms.com/api/v3/craft-elements-asset.html) itself. To access the resulting assets, you need to execute the query using `->one()` or `->all()`, which will give you either a single Asset object (or null) or an array of Asset objects (which may be empty).
  
  Please provide more info regarding the fields.
  
  > **Comments:**
  > **username_0**: I can't find the field 'infographics' of a particular section using the `craft\elements\Asset`  
  > **username_2**: @username_0 My answer was incorrect, I've misread the code in your question. Either way, you're not executing the asset query correctly, see my updated answer. If you provide more information, I can provide a more detailed answer.  
  
  ---
  
  