Answers.Body: <p>You need to execute the element query, then access the second element of the resulting array:</p>
  <pre class="lang-twig prettyprint-override"><code>{% set secondImage = entry.images.all()[1].url ?? null %}
  {% if secondImage %}
      {# … #}
  {% endif %}
  </code></pre>
  <p>The null coalescing operator (<code>??</code>) is useful here to prevent errors in case there aren't two images selected in the <code>images</code> field.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-14T16:27:14.527Z
Answers.Text: Just need to replace `images().` by `images.`
Answers.UserDisplayName: Nikolay Bronskiy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-14T16:28:35.900Z
Answers.Text: I can't edit it as stackexchange demand at least 6 changed characters :)
Answers.UserDisplayName: Nikolay Bronskiy
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-14T16:28:36.160Z
Answers.Text: @NikolayBronskiy Ah yes, good catch, slip of the pen :)
Answers.UserDisplayName: MoritzLost
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-14T15:35:16.523Z
Answers.LastActivityDate: 2023-03-14T16:28:12.830Z
Answers.LastEditDate: 2023-03-14T16:28:12.830Z
Answers.UserDisplayName: MoritzLost
Body: <p>In craft cms 3 we could use this:</p>
  <pre><code>{{ entry.images[1].url }}
  </code></pre>
  <p>But how can I get second asset in Craft CMS 4?</p>
  
Tags: <assets><craft4>
Title: How to get second asset in Craft CMS 4?
ThreadText: # How to get second asset in Craft CMS 4?
  
  (Asked by: username_0 on 2023-03-14)
  
  In craft cms 3 we could use this:
  
  ```
  {{ entry.images[1].url }}
  
  ```
  
  But how can I get second asset in Craft CMS 4?
  
  **Tags:** assets, craft4
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-03-14. Score: 2 | Accepted answer
  
  You need to execute the element query, then access the second element of the resulting array:
  
  ```twig
  {% set secondImage = entry.images.all()[1].url ?? null %}
  {% if secondImage %}
      {# … #}
  {% endif %}
  
  ```
  
  The null coalescing operator (`??`) is useful here to prevent errors in case there aren't two images selected in the `images` field.
  
  > **Comments:**
  > **username_0**: Just need to replace `images().` by `images.`  
  > **username_0**: I can't edit it as stackexchange demand at least 6 changed characters :)  
  > **username_1**: @username_0 Ah yes, good catch, slip of the pen :)  
  
  ---
  
  