Peter Knight Posted May 15, 2015 Share Posted May 15, 2015 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 More sharing options...
adrian Posted May 15, 2015 Share Posted May 15, 2015 Hi Peter, You can easily limit the images like this: foreach($i->Images->find("limit=5") as $image) { 4 Link to comment Share on other sites More sharing options...
Peter Knight Posted May 15, 2015 Author Share Posted May 15, 2015 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 1 Link to comment Share on other sites More sharing options...
adrian Posted May 15, 2015 Share Posted May 15, 2015 I hear ya - sometimes the brain reaches boiling point and I swear it just goes to mush I see masonry mentioned quite a bit around here, but just to add another option in case folks haven't seen it, I really like Freewall (http://vnjs.net/www/project/freewall/) 3 Link to comment Share on other sites More sharing options...
tpr Posted May 15, 2015 Share Posted May 15, 2015 I really like Freewall (http://vnjs.net/www/project/freewall/) Just tried a few similar jQuery plugin (including Freewall) to substitute the Uikit dynamic grid on a site but finally I went back to Uikit. It is very basic but easy to use. 4 Link to comment Share on other sites More sharing options...
Peter Knight Posted May 15, 2015 Author Share Posted May 15, 2015 They're both great masonary alternatives. Thanks for the share Link to comment Share on other sites More sharing options...
JeevanisM Posted April 22, 2020 Share Posted April 22, 2020 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 ? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now