Jump to content

Recommended Posts

Posted

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}'>";
   }
}
?>
Posted

Adrian - thanks. Been tying myself up in knots with this one.

Trying to integrate with jQuery Masonary grid fried my Friday evening brain.

Working now :)

  • Like 1
  • 4 years later...
Posted
On 5/15/2015 at 9:40 PM, adrian said:

Hi Peter,

You can easily limit the images like this:


foreach($i->Images->find("limit=5") as $image) {

this helped me ?

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
  • Recently Browsing   0 members

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