You are here

function opigno_content_set_default_image in Opigno 7

3 calls to opigno_content_set_default_image()
opigno_add_image_fields in ./opigno.install
opigno_update_7101 in ./opigno.install
Enable the course image field
opigno_update_7102 in ./opigno.install
Enable the course image field Add two new image styles for courses/classes

File

./opigno.install, line 451
Contains install instructions and logic

Code

function opigno_content_set_default_image(&$field, $filename, $source) {

  // Simulate an upload of the default user image
  $file = new stdClass();
  $file->filename = $filename;
  $file->timestamp = REQUEST_TIME;
  $file->uri = $source;
  $file->filemime = file_get_mimetype($source);
  $file->uid = 1;
  $file->status = 1;
  $file = file_copy($file, 'public://', FILE_EXISTS_REPLACE);
  $fid = $file->fid;

  // Set the default image
  $field['settings']['default_image'] = (string) $fid;
  field_update_field($field);
}