Jump to content

Echo and limit number of images


Peter Knight
 Share

Recommended Posts

Hi guys.

I know how to echo an Images field from a template called Portfolio and limit the echo to 5 results (5 pages)

$imagePages = $pages->find("template=Portfolio, limit=5");  

This assumes I have more than 1 page based on the template 'Portfiolio'.

But what if I have a single page based on Portfolio and only want the first 5 images from that single page?

The following doesn't work as limit applies to the pages and not the images field:

<?php

$imagePages = $pages->find("template=Portfolio, limit=5");  
	
 foreach($imagePages as $i) {	

  foreach($i->Images as $image) {
					
   $thumb = $image->size(100, 100);
   echo "<img src='{$thumb->url}'>";
   }
}
?>
Link to comment
Share on other sites

  • 4 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...