Index: asset_bytype/asset_bytype.info
===================================================================
--- asset_bytype/asset_bytype.info	(revision 0)
+++ asset_bytype/asset_bytype.info	(revision 0)
@@ -0,0 +1,5 @@
+; $Id$
+name = Asset By Type
+description = Provides asset fields to the theme layer conveniently organized by file type
+dependencies = asset content
+package = Asset
Index: asset_bytype/asset_bytype.module
===================================================================
--- asset_bytype/asset_bytype.module	(revision 0)
+++ asset_bytype/asset_bytype.module	(revision 0)
@@ -0,0 +1,33 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_nodeapi().
+ */
+function asset_bytype_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
+  switch ($op) {
+    case 'view':
+      foreach ($node as $fieldname => $value) {
+      if (substr($fieldname, 0, 6)=="field_") {
+        // For each cck field, check if it's an asset field
+        $fields = content_fields($fieldname, $node->type);
+        if ($fields['type']=="asset") { // The asset computer name is "asset"
+          $field = $node->$fields['field_name'];
+          foreach ($field as $key => $value) {
+            $asset = asset_load($field[$key]['aid']);
+            // Add the html code for the preview
+            if ($asset) {
+              $preview = asset_preview($field[$key]['aid']);
+              if (!$node->assets_bytype) {
+                $node->assets_bytype = array();
+              }
+              $node->assets_bytype[$fieldname]['extension'][$asset->extension][] = $preview;
+              $node->assets_bytype[$fieldname]['type'][$asset->type][] = $preview;
+            }
+          }
+        }
+      }
+    }
+    break;
+  }
+}
