Yes, it did the trick for the "last x days"-function. But now pictures that are sorted into more than one category don't get displayed on a category's gallery home.
Image XYZ is sorted into user album A and category B. If I apply the code change you proposed, the following happens:
- the double-image bug is fixed. No more double images in the "last x days"-function
- the image is still visible in gallery view of user album A.
- the image is not visible in gallery view of category B.
Clearly, this is not a feasible option, so I undid the changes to showgallery.php. Sorry to be a nuisance, but I think this is quite fundamental.