I'm attempting to change the view mode of a media field programmatically. I've created a view mode called 'modal'. I created a mytheme_preprocess_media hook and attempted to change the view mode a variety ways like
mytheme_preprocess_media(&$variables) {
$variables['view_mode'] = 'modal';
$variables['elements']['#view_mode'] = 'modal';
$variables['content']['field_media_oembed_video']['#view_mode'] = 'modal';
}
but none seem to work. Using xdebug I know for sure that this hook is being hit but for some reason it always uses the default view mode.
How can I programmatically change the view mode of a media field?