I would like to change the "Image style" of some Image fields in some given view modes, which are attached to particular content types; I would like to do this programmatically.
This is what I would like to change:
How should I do this?
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.Sign up to join this community
Something like this should do it:
$entity_type = 'node'; $bundle = 'article'; $field_name = 'field_image'; $view_mode = 'default'; // Get the instance info $instance_info = field_info_instance($entity_type, $field_name, $bundle); // Change the image style $instance_info['display'][$view_mode]['settings']['image_style'] = 'new_image_style'; // Save it field_update_instance($instance_info);