Jump to content

apply limit to random


Peter Knight
 Share

Recommended Posts

Someone suggested that an easy way to output a random image from a field was to use getRandom and then simply use limit=1

I'm not sure where I apply it to the following

<?php
$randomitem = $pages->get(1034)->images->getRandom();
foreach($randomitem as $item) {
echo "
<img src='{$item->url}' class='squares'>

";} 

?>

Does it go at the start where I define my variable or somewhere in the echo statment?

Thanks

Link to comment
Share on other sites

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...