--- emimage.theme.inc.orig	2009-05-10 02:31:20.000000000 +0200
+++ emimage.theme.inc	2009-05-10 23:23:28.437500000 +0200
@@ -5,14 +5,18 @@ function theme_emimage_image($field, $it
   $url = module_invoke('emfield', 'include_invoke', 'emimage', $item['provider'], 'image_url', $code, $width, $height, $formatter, $field, $item, $node);
   $attributes = array();
   if ($width == 0) {
+    $attributes['height'] = $height;
+  } 
+  elseif ($height == 0) {
     $attributes['width'] = $width;
   }
   else {
     // Find out the size of the actual image file, and scale accordingly
-    if ( $item['data']['width'] && $item['data']['height'] ) {
+    $item_data = unserialize($item['data'][0]);
+    if ( $item_data['width'] && $item_data['height'] ) {
       // The image's width & height are known
-      $scale_width = $item['data']['width'] / $width ;
-      $scale_height = $item['data']['height'] / $height ;
+      $scale_width = $item_data['width'] / $width ;
+      $scale_height = $item_data['height'] / $height ;
       if ($scale_width > $scale_height) {
         $attributes['width'] = $width;
       } 
