Don't assume the gallery will always have images.
authorMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 30 Aug 2010 20:16:40 +0000 (16:16 -0400)
committerMichael J. Rubinsky <mrubinsk@horde.org>
Mon, 30 Aug 2010 20:16:40 +0000 (16:16 -0400)
Bug: 9200

ansel/lib/ImageGenerator.php

index 15a9ff1..a4e9457 100644 (file)
@@ -179,9 +179,11 @@ class Ansel_ImageGenerator
             $rnd = mt_rand(0, $cnt);
             try {
                 $temp = $gallery->getImages($rnd, 1);
-                $aimg = array_shift($temp);
-                $aimg->load('screen');
-                $images[] = $aimg->getHordeImage();
+                if (count($temp)) {
+                    $aimg = array_shift($temp);
+                    $aimg->load('screen');
+                    $images[] = $aimg->getHordeImage();
+                }
             } catch (Exception $e) {
                 Horde::logMessage($e, 'ERR');
             }