Jump to content

Get all images from all pages?


antknight
 Share

Recommended Posts

// 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; 

 

  • Like 5
Link to comment
Share on other sites

... 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;
    }
}
  • Like 11
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...