--- image_gallery.module	2007-09-07 19:26:58.000000000 +0000
+++ image_gallery.module.hide_empty_galleries	2008-02-01 12:52:16.000000000 +0000
@@ -88,6 +88,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."),
+  );
 
   return system_settings_form($form);
 }
@@ -337,17 +343,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(), NULL, NULL, FALSE, 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(), NULL, NULL, FALSE, 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";
   }
