How to hide an image field from teaser view if video field has data? foreach($view-&gt;result as $value){
     if($value-&gt;_entity-&gt;field_videos-&gt;getValue()[0]['target_id']){
      kint($value-&gt;_entity-&gt;field_blogimage)
    }


I am getting following image by kint, I need to set exclude to 0 for image field of this view in views_pre_render hook in drupal 8.
function mymodule_entity_view_mode_alter(&amp;$view_mode, Drupal\Core\Entity\
  EntityInterface $entity, $context) {
  // For nodes, change the view mode when it is teaser.
  $current_path = \Drupal::service('path.current')-&gt;getPath();
  if($current_path=='/dblog'){
    if ($entity-&gt;getEntityTypeId() == 'node') {
        // kint($entity-&gt;getFields()['field_videos']
        //  -&gt;getValue()[0]['target_id']);
        if(!(empty($entity-&gt;getFields()['field_videos']
        -&gt;getValue()[0]['target_id']))){
        $view_mode='single';
        }
    }

  }

}


well in my case, i solved my problem like this, i created new view mode with needed fields and switched view modes using above hooks.I think this one is a good alternative.Thanks Guys
@OPTASY Canada
@Chriss Happy