Support

Account

Home Forums ACF PRO Get different image size after 5th item Reply To: Get different image size after 5th item

  • Are you using a gallery field or some other type of image field? A gallery field returns an array of image objects. An example is given on this page http://www.advancedcustomfields.com/resources/gallery/

    You’d basically need to create a loop to loop through the array and then change the image you used after the 5th one.

    
    for ($i=0; $i<count($images); $i++) {
      if ($i<5) {
        $size = 'thumbnail';
      } else {
        $size = 'large';
      }
      echo $images[$i]['sizes'][$size],'<br>';
      echo $images[$i]['sizes'][$size.'-width'],'<br>';
      echo $images[$i]['sizes'][$size.'-height'],'<br>';
    }