title: ACF count gallery images
body: <p>I am trying to make an grid of different size images using the ACF gallery field.</p>
  
  <p>I have managed to do this before in a repeater field by counting rows, but have unable to adjust this to work with the gallery field.</p>
  
  <p>My aim is to have a grid of 10 images using 2 different image sizes.</p>
  
  <ul>
  <li>Images 1, 2, 3, 6, 7, 8 would be one size</li>
  <li>Images 4, 5, 9, 10 would be a different size</li>
  </ul>
  
  <p>My current markup is:</p>
  
  <pre><code>&lt;?php 
      $images = get_field('home-image-grid');
      $size = 'full';
      if( $images ): 
  ?&gt;
      &lt;ul&gt;
          &lt;?php foreach( $images as $image ): ?&gt;
              &lt;li&gt;
                  &lt;?php echo wp_get_attachment_image( $image['ID'], $size ); ?&gt;
              &lt;/li&gt;
          &lt;?php endforeach; ?&gt;
      &lt;/ul&gt;
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>I have tried the markup I used previously with a repeater field, but this only outputs image 1. </p>
  
  <pre><code>&lt;?php 
      $i = 1;
      $images = get_field('home-image-grid');
      $size = 'full';
      if( $images ): 
  ?&gt;
  
      &lt;?php foreach( $images as $image ): ?&gt;
  
          &lt;?php if ( $i == 1 ) { ?&gt;
              image 1
          &lt;?php } elseif ( $i == 2 ) { ?&gt;
              image 2
          &lt;?php } elseif ( $i == 3 ) { ?&gt;
              image 3
          &lt;?php } elseif ( $i == 4 ) { ?&gt;
              image 4
          &lt;?php } ?&gt;
  
      &lt;?php endforeach; ?&gt;
  
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>I presume this is because of the foreach statement. How can I get this to work?</p>