--- image_gallery.module.old	2008-08-18 16:59:55.000000000 +0200
+++ image_gallery.module	2008-08-18 17:18:30.000000000 +0200
@@ -84,6 +84,12 @@ function image_gallery_admin_settings() 
     '#default_value' => variable_get('image_gallery_node_info', 0),
     '#description' => t("Checking this will display the \"Posted by\" node information on the gallery pages."),
   );
+  $form['gallery']['image_gallery_list_empty_galleries'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('List empty galleries'),
+    '#default_value' => variable_get('image_gallery_list_empty_galleries', 1),
+    '#description' => t("Checking this will always list galleries, even if they are empty."),
+  ); 
   $form['gallery']['image_gallery_sort_order'] = array(
     '#type' => 'radios',
     '#title' => t('Image display sort order'),
@@ -391,17 +397,22 @@ function theme_image_gallery($galleries,
   if (count($galleries)) {
     $content .= '<ul class="galleries">';
     foreach ($galleries as $gallery) {
-      $content .= '<li class="clear-block">';
-      if ($gallery->count) {
-        $content .= l(image_display($gallery->latest, IMAGE_THUMBNAIL), 'image/tid/'. $gallery->tid, array('html' => TRUE));
+      if(!variable_get('image_gallery_list_empty_galleries', 1) and !($gallery->count)){
+        //don't display empty galleries
       }
-      $content .= "<h3>". l($gallery->name, 'image/tid/'. $gallery->tid) ."</h3>\n";
-      $content .= '<div class="description">'. check_markup($gallery->description) ."</div>\n";
-      $content .= '<p class="count">'. format_plural($gallery->count, 'There is 1 image in this gallery', 'There are @count images in this gallery') ."</p>\n";
-      if ($gallery->latest->changed) {
-        $content .= '<p class="last">'. t('Last updated: %date', array('%date' => format_date($gallery->latest->changed))) ."</p>\n";
+      else {
+        $content .= '<li class="clear-block">';
+        if ($gallery->count) {
+          $content .= l(image_display($gallery->latest, IMAGE_THUMBNAIL), 'image/tid/'. $gallery->tid, array('html' => TRUE));
+        }
+        $content .= "<h3>". l($gallery->name, 'image/tid/'. $gallery->tid) ."</h3>\n";
+        $content .= '<div class="description">'. check_markup($gallery->description) ."</div>\n";
+        $content .= '<p class="count">'. format_plural($gallery->count, 'There is 1 image in this gallery', 'There are @count images in this gallery') ."</p>\n";
+        if ($gallery->latest->changed) {
+          $content .= '<p class="last">'. t('Last updated: %date', array('%date' => format_date($gallery->latest->changed))) ."</p>\n";
+        }
+        $content .= "</li>\n";
       }
-      $content .= "</li>\n";
     }
     $content .= "</ul>\n";
   }
