antknight Posted May 19, 2013 Share Posted May 19, 2013 I can't find anything similar in the forums. How would I grab all images from all the images fields from all pages? Link to comment Share on other sites More sharing options...
ryan Posted May 19, 2013 Share Posted May 19, 2013 // assuming your images field is named "images": $pagesWithImages = $pages->find("images.count>0"); // now that you have all pages with images, you can put them all in 1 array if you want $allImages = array(); foreach($pagesWithImages as $p) { foreach($p->images as $image) $allImages[] = $image; } 5 Link to comment Share on other sites More sharing options...
teppo Posted May 19, 2013 Share Posted May 19, 2013 ... and assuming that you don't / can't add all image field names in your code, something like this should also work: $allImages = array(); foreach ($fields->find("type=FieldtypeImage") as $f) { foreach ($pages->find("$f.count>0") as $p) { foreach ($p->$f as $i) $allImages[] = $i; } } 11 Link to comment Share on other sites More sharing options...
antknight Posted May 19, 2013 Author Share Posted May 19, 2013 Thanks for taking the time Ryan, once again so simple. 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