Jump to content
Peter Knight

apply limit to random

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

$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?


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...