getNumImages subalbums

Hi all,
the function getNumImages() counts right now only the images in the album directly but not the images which are in subalbums.
Is there a way to change it?

Thx,
Freindler

Comments

  • You would have to recursively sum all subalbum numImages.

    something like this should work:
    `function totalImages($album) {

    global $_zp_gallery;

    $sum = $album->getNumImages();

    $subalbums = $album->getSubalbums(0);

    while (count($subalbums) > 0) {

    $albumname = array_pop($subalbums);

    $album = new Album($_zp_gallery, $albumname);

    $sum = $sum + totalImages($album);

    }

    return $sum;

    }`

    Caveat: I have not tried this.
  • This does indeed work, although it is slightly different than the `getNumImages()` function. You must include the album as an argument, generally you would use `totalImages($_zp_current_album)` (that's how I use it for each album on my index page).
  • thanks a lot,
    it works perfectly,..
    right now i've included it in my "theme-functions.php" mit a different name (bsetotalImages).
    I will be nice if the developing team will include it in the zp-core ;)
    thanks,
    freindler
  • Will do, thanks for testing it out.
Sign In or Register to comment.