Add class to views row instead of replace system classes
Your question is simply a PHP programming question, and not entirely Drupal related. But here goes:

function theme_preprocess_views_view_unformatted(&amp;$vars) {
  $view = $vars['view'];
  $rows = $vars['rows'];

foreach ($vars['view']-&gt;result as $id =&gt; $row) {

    if (!empty($row-&gt;field_field_image)) {
      $old_class_values = $vars['classes_array'][$id];
      $vars['classes_array'][$id] = $old_class_values . ' has_field';
    }  
    else {
      $vars['classes_array'][$id] = $old_class_values . ' has_no_field';
    }
  }
}