--- brilliant_gallery.module.original	2007-10-11 10:28:47.000000000 +1300
+++ brilliant_gallery.module	2007-10-15 17:39:21.000000000 +1300
@@ -234,13 +234,14 @@
         if ( $thisfolder <> '' ) {
              $result .= ' align="center"';
            }
-        $result .= ' style="width:' . $columns*$imagewidth . 'px;">'; #cell-spacing: 5px;
+        $result .= ' style="width:' . $columns*$imagewidth . 'px;">' . "\n"; #cell-spacing: 5px;
         for ( $poct = 1; $poct <= $maxpoct; $poct++ ) {
                $fullimgpath = $path . '/' . $retval[$poct-1];
                if ($column_count == 0) { $result .= ('<tr>'); }
-               $result .= ('<td align="center" bgcolor="' . $bgcolour . '" style="padding: ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px;vertical-align: middle;">');
+               $result .= ('<td align="center" bgcolor="' . $bgcolour . '" style="padding: ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px ' . $padding . 'px;vertical-align: middle;">' . "\n");
                     $pocetobr += 1;
                     if ( substr( strtolower( $retval[$poct-1] ), -4, 4 ) == ".jpg" or substr( strtolower( $retval[$poct-1] ), -5, 5 ) == ".jpeg" or substr( strtolower( $retval[$poct-1] ), -4, 4 ) == ".gif" or substr( strtolower( $retval[$poct-1] ), -4, 4 ) == ".png" ) {
+						  $caption = str_replace(array('.', '_'), array(' ', '<br>'), basename($retval[$poct-1], strrchr($retval[$poct-1], '.')));
                          $smallenough = false;
                          # Is image horizontally or vertically oriented?
                            $temp = getimagesize( $absolpath . '/' . $retval[$poct-1] );
@@ -296,30 +297,30 @@
                              break;
                          }
 
-                         $result .= '>';
+                         $result .= ' title="' . $caption . '">';
                          # Important to begin with the "/" otherwise thumbnails in non-root folders fail. See http://drupal.org/node/175292
                          $modulepath = url(drupal_get_path('module', 'brilliant_gallery'), NULL, NULL, TRUE);
                          # Non-clean URLs need removing ?q=
                            $modulepath = str_replace( "?q=", "",  $modulepath );
                          $result .= '<img style="display: block;border:0" src="' . $modulepath .'/image.php?imgp=' . base64_encode( $absolpath . '/' . $retval[$poct-1] ) . '&imgw=' . $imgw . '&imgh=' . $imgh . '" />'; # width="' . $imgw . '"
-                         $result .= '</a>';
+                         $result .= '</a>' . "\n";
 
                        } else {
                          $result .= '<a href="' . $fullimgpath . '">';
                          $result .= '<center>' . $retval[$poct-1] . '</center>';
-                         $result .= '</a>';
+                         $result .= '</a>' . "\n";
 
                        }
-                    $result .= '</td>';
+                    $result .= '</td>' . "\n";
 
                $column_count += 1;
-               if ($column_count == $columns) { $result .= ("</tr>"); $column_count = 0; }
+               if ($column_count == $columns) { $result .= ("</tr>\n"); $column_count = 0; }
                }
-         if ($column_count <> 0) { $result .= ("</tr>"); }
+         if ($column_count <> 0) { $result .= ("</tr>\n"); }
          if ( $loggedin === true ) {
-              $result .= '<tr><td colspan="' . $maxpoct . '"><div align="right"><input type="submit" value="Submit favourite image rating"</div></td></tr>';
+              $result .= '<tr><td colspan="' . $maxpoct . '"><div align="right"><input type="submit" value="Submit favourite image rating"</div></td></tr>' . "\n";
             }
-         $result .= "</table>"; 
+         $result .= "</table>\n"; 
          return $result;
    }
 
