Index: chessboard.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/chessboard/chessboard.module,v
retrieving revision 1.73
diff -u -p -r1.73 chessboard.module
--- chessboard.module	21 Nov 2010 21:31:14 -0000	1.73
+++ chessboard.module	27 Nov 2010 20:56:56 -0000
@@ -163,7 +163,7 @@ function chessboard_theme() {
 }
 
 /**
- * Add to the page structures attached to a render element structure.
+ * Add structures attached to an element, forcing media 'all', preprocess FALSE.
  *
  * A CSS structure is attached
  * to elements using the #attached property. The #attached property contains an
@@ -181,17 +181,19 @@ function chessboard_theme() {
  * @see drupal_add_css()
  */
 function chessboard_process_attached($elements) {
+  $options = array('media' => 'all', 'preprocess' => FALSE);
   $elements['#attached'] += array('css' => array());
-  foreach ($elements['#attached']['css'] as $data) {
-    if (is_string($data)) {
-      drupal_add_css($data, 'module', 'all', FALSE);
-    }
+  $elements['#attached']['css'] = array_filter($elements['#attached']['css'], 'is_string');
+  foreach ($elements['#attached']['css'] as $index => $data) {
+    $elements['#attached']['css'][$data] = $options;
+    $elements['#attached']['css'][$index] = FALSE;
   }
-  return TRUE;
+  $elements['#attached']['css'] = array_filter($elements['#attached']['css']);
+  return _chessboard_process_attached($elements);
 }
 
 /**
- * Renders HTML given a structured array tree.
+ * Renders HTML given a render array, forcing css media 'all', preprocess FALSE.
  *
  * @see drupal_render()
  *
@@ -380,6 +382,39 @@ function _chessboard_filter_page_structu
   return $cids;
 }
 
+/**
+ * Add to the page structures attached to a render element structure.
+ *
+ * A CSS structure is attached
+ * to elements using the #attached property. The #attached property contains an
+ * associative array, where the keys are the the types of the structure, and
+ * the value the attached data. For example:
+ * @code
+ * $build['#attached'] = array(
+ *   'css' => array(
+ *     drupal_get_path('module', 'chessboard') . '/chessboard.css' => array(),
+ *   ),
+ * );
+ * @endcode
+ *
+ * @param $elements
+ *   The structured array describing the data being rendered.
+ *
+ * @see drupal_add_css()
+ */
+function _chessboard_process_attached($elements) {
+  $elements['#attached'] += array('css' => array());
+  foreach ($elements['#attached']['css'] as $data => $options) {
+    if (!is_array($options)) {
+      $data = $options;
+      $options = array();
+    }
+    $options += array('media' => 'all', 'preprocess' => TRUE);
+    drupal_add_css($data, 'module', $options['media'], $options['preprocess']);
+  }
+  return TRUE;
+}
+
 function chessboard_formatter_view($items) {
   $element = array(
     '#attached' => array(
