Add class to views row if image fields has content I have views which has multiple image fields. In some cases all those image fields are empty, but some cases one of them has content.

When image field has content I want to have extra class .has-image for views row.

There is image fields: image_field_1, image_field_2 and image_field_3

It can be done programmatically, but I'm lost how to check those fields.
I know this much:

function YOURTHEME_preprocess_views_view_unformatted(&amp;$vars){



SOLUTION

There can not be used $vars['classes_array'][$id][] because $classes_array[$id] is not an array.

Here is code for working solution. 

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) || !empty($row-&gt;field_field_image_2) || !empty($row-&gt;field_field_image_3)) {
      $vars['classes_array'][$id] .= ' has_field';
    }  
    else {
      $vars['classes_array'][$id] .= ' has_no_field';
    }
  }
}
When you use the preprocess function you find the result in 

$vars['view']-&gt;result


and the corresponding classes array under 

$vars['classes_array']


where in results and in classes array the corresponding rows have the same key.

You can do now something like this in your preprocess function:

foreach ($vars['view']-&gt;result as $rid =&gt; $row) {
  if (isset($row-&gt;YOUR_FIELD) &amp;&amp; !empty($row-&gt;YOUR_FIELD)) {
    $vars['classes_array'][$rid][] = 'has_field';
  }  
  else {
    $vars['classes_array'][$rid][] = 'has_no_field';
  }
}


It is untested and just a little scribble but maybe it helps you.