I'd like to programmatically change an image style during hook_node_view(), and I thought this would be relatively straightforward like so:
/**
* Implements hook_node_view()
*/
function example_node_view($node, $view_mode, $langcode) {
if (example_ok()) {
$node->content['field_image'][0]['#image_style'] = 'new_image_style';
}
}
Unfortunately this does not work. I'm aware of the picture and breakpoints modules, and am in fact using them, however there are sometimes when a dynamic decision needs to be made that these modules don't cover.