next_image() troubleshooting when not displaying images

I have altered my theme to detect when it is showing images by evaluating whether next_image() returns TRUE or FALSE. I then present some html bits if it evaluates TRUE and also go through the while loop to show all the images of an album.
The problem is that most of the time it works, but in some albums it wont show any photos, although it does evaluate to TRUE.

if(next_image(TRUE, NULL, NULL))
{
//do bits here ?>
<div id="thumbcontainer">
<?php while (next_image(TRUE, NULL, NULL)): ?>
// print thumbs
<?php endwhile; ?>
</div>
<?php
// do some more bits here
}

If I just leave the while loop it goes through all images. If I include it in the if statement, it does not, although the it evaluates to TRUE. Please note this 'unexpected behaviour' happens only in very few albums.

Any ideas why next_image() would not return images?

Comments

  • acrylian Administrator, Developer
    If you want to check if an album actually has images so you only print the html of the loop then, the better way would be using `if(getNumImages()) { … }`. Same for `next_album` using `getNumAlbums()`.
  • vstam Member
    I used getNumImages() in the if statement instead of next_image() and it works as expected. Thank so much! It's been driving me mad. :)
Sign In or Register to comment.