Features - set image field default value

Public

Get raw version
php
  1. /*
  2.  * Implementation of hook_post_features_revert().
  3.  */
  4. function mymod_post_features_revert($component) {
  5. if ($component == 'field_instance') {
  6. $field_instance = field_info_instance('node', 'field_image', 'my_bundle');
  7. $data = file_get_contents(drupal_get_path('theme', 'my_theme') .'/images/default.png');
  8. $file = file_save_data($data, 'public://default.png', FILE_EXISTS_RENAME);
  9. $field_instance['settings']['default_image'] = $file->fid;
  10. field_update_instance($field_instance);
  11. }
  12. }