How to hide an image field from teaser view if video field has data?
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