Index: chessboard_render.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chessboard/chessboard_render.php,v
retrieving revision 1.16.2.11
diff -u -p -r1.16.2.11 chessboard_render.php
--- chessboard_render.php	30 Nov 2010 21:12:24 -0000	1.16.2.11
+++ chessboard_render.php	11 Dec 2010 20:54:28 -0000
@@ -111,22 +111,58 @@ function template_preprocess_chessboard(
 
   if (!isset($variables['element']['#image_directory_path'])) {
     $variables['element']['#image_directory_path'] = drupal_get_path('module', 'chessboard') . '/default';
-    $getsize = TRUE;
-  }
-  else {
-    $getsize_test_path = chessboard_piece_filename('-', 0, $variables['element']['#image_directory_path'] . '/');
-    $getsize = is_file($getsize_test_path) && (list($width, $height) = @getimagesize($getsize_test_path));
   }
   $image_directory_path = $variables['element']['#image_directory_path'];
   if (!isset($tables_xhtml[$image_directory_path])) {
+    $group_attributes = array();
+    if ($image_directory_path === drupal_get_path('module', 'chessboard') . '/default') {
+      $group_attributes['square'] = array(
+        'width' => 40,
+        'height' => 40,
+      );
+      $group_attributes['border-h'] = array(
+        'width' => 40,
+        'height' => 4,
+      );
+      $group_attributes['border-v'] = array(
+        'width' => 4,
+        'height' => 40,
+      );
+      $group_attributes['border-c'] = array(
+        'width' => 4,
+        'height' => 4,
+      );
+    }
+    else {
+      $info = array(
+        'square' => chessboard_piece_filename('-', 0, $image_directory_path . '/'),
+        'border-h' => chessboard_border_filename('T', $image_directory_path . '/'),
+        'border-v' => chessboard_border_filename('R', $image_directory_path . '/'),
+        'border-c' => chessboard_border_filename('TR', $image_directory_path . '/'),
+      );
+      foreach ($info as $group => $getsize_test_path) {
+        if (is_file($getsize_test_path) && (list($width, $height) = @getimagesize($getsize_test_path))) {
+          $group_attributes[$group] = array(
+            'width' => $width,
+            'height' => $height,
+          );
+        }
+      }
+    }
+
+    // Append class atttribute.
+    foreach ($group_attributes as $group => $attributes) {
+      $group_attributes[$group]['class'] = 'chessboard-' . $group;
+    }
+
     // Construct the translation table
 
     // Empty and marked squares
     $table_xhtml = array(
-      '-0' => theme('image', chessboard_piece_filename('-', 0, $image_directory_path . '/'), '-', NULL, array('class' => 'chessboard-square'), $getsize),
-      '-1' => theme('image', chessboard_piece_filename('-', 1, $image_directory_path . '/'), '-', NULL, array('class' => 'chessboard-square'), $getsize),
-      'x0' => theme('image', chessboard_piece_filename('x', 0, $image_directory_path . '/'), 'x', NULL, array('class' => 'chessboard-square'), $getsize),
-      'x1' => theme('image', chessboard_piece_filename('x', 1, $image_directory_path . '/'), 'x', NULL, array('class' => 'chessboard-square'), $getsize),
+      '-0' => strtr(theme('image', chessboard_piece_filename('-', 0, $image_directory_path . '/'), '-', NULL, $group_attributes['square'], FALSE), array('"  ' => '" ')),
+      '-1' => strtr(theme('image', chessboard_piece_filename('-', 1, $image_directory_path . '/'), '-', NULL, $group_attributes['square'], FALSE), array('"  ' => '" ')),
+      'x0' => strtr(theme('image', chessboard_piece_filename('x', 0, $image_directory_path . '/'), 'x', NULL, $group_attributes['square'], FALSE), array('"  ' => '" ')),
+      'x1' => strtr(theme('image', chessboard_piece_filename('x', 1, $image_directory_path . '/'), 'x', NULL, $group_attributes['square'], FALSE), array('"  ' => '" ')),
     );
 
     // Pieces
@@ -134,23 +170,23 @@ function template_preprocess_chessboard(
     for ($i=0; $i<6; $i++) {
       $piece = $pieces[$i];
       $table_xhtml += array(
-        strtoupper($piece) . '0' => theme('image', chessboard_piece_filename(strtoupper($piece), 0, $image_directory_path . '/'), strtoupper($piece), NULL, array('class' => 'chessboard-square'), $getsize),
-        strtoupper($piece) . '1' => theme('image', chessboard_piece_filename(strtoupper($piece), 1, $image_directory_path . '/'), strtoupper($piece), NULL, array('class' => 'chessboard-square'), $getsize),
-        $piece . '0' => theme('image', chessboard_piece_filename($piece, 0, $image_directory_path . '/'), $piece, NULL, array('class' => 'chessboard-square'), $getsize),
-        $piece . '1' => theme('image', chessboard_piece_filename($piece, 1, $image_directory_path . '/'), $piece, NULL, array('class' => 'chessboard-square'), $getsize),
+        strtoupper($piece) . '0' => strtr(theme('image', chessboard_piece_filename(strtoupper($piece), 0, $image_directory_path . '/'), strtoupper($piece), NULL, $group_attributes['square'], FALSE), array('"  ' => '" ')),
+        strtoupper($piece) . '1' => strtr(theme('image', chessboard_piece_filename(strtoupper($piece), 1, $image_directory_path . '/'), strtoupper($piece), NULL, $group_attributes['square'], FALSE), array('"  ' => '" ')),
+        $piece . '0' => strtr(theme('image', chessboard_piece_filename($piece, 0, $image_directory_path . '/'), $piece, NULL, $group_attributes['square'], FALSE), array('"  ' => '" ')),
+        $piece . '1' => strtr(theme('image', chessboard_piece_filename($piece, 1, $image_directory_path . '/'), $piece, NULL, $group_attributes['square'], FALSE), array('"  ' => '" ')),
       );
     }
 
     // Borders
     $table_xhtml += array(
-      'T' => theme('image', chessboard_border_filename('T', $image_directory_path . '/'), '', NULL, array('class' => 'chessboard-border-h'), $getsize),
-      'B' => theme('image', chessboard_border_filename('B', $image_directory_path . '/'), '', NULL, array('class' => 'chessboard-border-h'), $getsize),
-      'L' => theme('image', chessboard_border_filename('L', $image_directory_path . '/'), '', NULL, array('class' => 'chessboard-border-v'), $getsize),
-      'R' => theme('image', chessboard_border_filename('R', $image_directory_path . '/'), '', NULL, array('class' => 'chessboard-border-v'), $getsize),
-      'TL' => theme('image', chessboard_border_filename('TL', $image_directory_path . '/'), '', NULL, array('class' => 'chessboard-border-c'), $getsize),
-      'TR' => theme('image', chessboard_border_filename('TR', $image_directory_path . '/'), '', NULL, array('class' => 'chessboard-border-c'), $getsize),
-      'BL' => theme('image', chessboard_border_filename('BL', $image_directory_path . '/'), '', NULL, array('class' => 'chessboard-border-c'), $getsize),
-      'BR' => theme('image', chessboard_border_filename('BR', $image_directory_path . '/'), '', NULL, array('class' => 'chessboard-border-c'), $getsize),
+      'T' => strtr(theme('image', chessboard_border_filename('T', $image_directory_path . '/'), '', NULL, $group_attributes['border-h'], FALSE), array('"  ' => '" ')),
+      'B' => strtr(theme('image', chessboard_border_filename('B', $image_directory_path . '/'), '', NULL, $group_attributes['border-h'], FALSE), array('"  ' => '" ')),
+      'L' => strtr(theme('image', chessboard_border_filename('L', $image_directory_path . '/'), '', NULL, $group_attributes['border-v'], FALSE), array('"  ' => '" ')),
+      'R' => strtr(theme('image', chessboard_border_filename('R', $image_directory_path . '/'), '', NULL, $group_attributes['border-v'], FALSE), array('"  ' => '" ')),
+      'TL' => strtr(theme('image', chessboard_border_filename('TL', $image_directory_path . '/'), '', NULL, $group_attributes['border-c'], FALSE), array('"  ' => '" ')),
+      'TR' => strtr(theme('image', chessboard_border_filename('TR', $image_directory_path . '/'), '', NULL, $group_attributes['border-c'], FALSE), array('"  ' => '" ')),
+      'BL' => strtr(theme('image', chessboard_border_filename('BL', $image_directory_path . '/'), '', NULL, $group_attributes['border-c'], FALSE), array('"  ' => '" ')),
+      'BR' => strtr(theme('image', chessboard_border_filename('BR', $image_directory_path . '/'), '', NULL, $group_attributes['border-c'], FALSE), array('"  ' => '" ')),
     );
     $tables_xhtml[$image_directory_path] = $table_xhtml;
   }
