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>';
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.