Index: galleria.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/galleria/galleria.module,v
retrieving revision 1.1.2.13
diff -u -r1.1.2.13 galleria.module
--- galleria.module	23 Mar 2009 14:40:16 -0000	1.1.2.13
+++ galleria.module	25 Apr 2009 20:44:34 -0000
@@ -29,8 +29,9 @@
  * Helper to ensure file extension is an image
  */
 function galleria_validate_file_extensions($files) {
+  global $allowed_extensions;
   $allowed_extensions = array('jpg', 'png', 'jpeg', 'gif');
-  $valid = TRUE;
+  $valid = FALSE;
 
   // check each file extension
   foreach ($files as $file) {
@@ -38,8 +39,8 @@
     if (substr($ext, 0, 1) == '.') {
       $ext = substr($ext, 1, 3);
     }
-    if (!in_array($ext, $allowed_extensions)) {
-      $valid = FALSE;
+    if (in_array($ext, $allowed_extensions)) {
+      $valid = TRUE;
     }
   }
 
@@ -65,7 +66,7 @@
     // are there attachments?
     if (!empty($node->files)) {
       if (!($valid = galleria_validate_file_extensions($node->files))) {
-        galleria_set_message(t('Invalid Galleria: one or more attached files are not images.'), 'error');
+        galleria_set_message(t('Invalid Galleria: at least one attachment must be an image.'), 'error');
       }
     }
     else {
@@ -235,6 +236,7 @@
  * Preprocess the galleria variables.
  */
 function template_preprocess_galleria(&$vars) {
+  global $allowed_extensions;
   $node = $vars['node'];
   $files = $node->files;
   $images = array();
@@ -245,6 +247,13 @@
   $thumb_preset = variable_get('galleria_thumb_imagecache_preset', '');
 
   foreach ($files as $file) {
+    $ext = strtolower(substr($file->filename, -4));
+    if (substr($ext, 0, 1) == '.') {
+      $ext = substr($ext, 1, 3);
+    }
+    if (!in_array($ext, $allowed_extensions)) {
+      continue;
+    }
     $caption = $file->description != $file->filename ? $file->description : '';
     $url = $file->filepath;
 

