Display Suite code field – how to use another image field conditionally
It's because you have nothing in renderable format yet.

Look at function field_view_field


  Returns a renderable array for the value of a single field in an
  entity.


Then change your code like this:

&lt;?php 
dsm($entity);
if(empty($entity-&gt;field_thumbnail)){
    $renderable = field_view_field('node',$entity,'field_main_image',array('settings' =&gt; array('image_style' =&gt; 'thumbnail')));
    print drupal_render($renderable );
}
?&gt;


Note that this is not the only way to get html from field values. You can use theme functions and load that with values you find on $entity object and print that if you wish.