You are here

function drupal_commons_config_images in Drupal Commons 6.2

Same name and namespace in other branches
  1. 6 drupal_commons.profile \drupal_commons_config_images()

Configure default images

The group and profile default images need to be processed by ImageCache and stored in the files directory

1 string reference to 'drupal_commons_config_images'
drupal_commons_profile_tasks in ./drupal_commons.profile
Perform any final installation tasks for this profile.

File

./drupal_commons.profile, line 387

Code

function drupal_commons_config_images() {

  // Copy default user image to files directory
  $user_image = 'profiles/drupal_commons/images/default-user.png';
  file_copy($user_image, 0, FILE_EXISTS_REPLACE);

  // Defaults to files directory
  // Copy default group image to files directory
  $group_image = 'profiles/drupal_commons/images/default-group.png';
  file_copy($group_image, 0, FILE_EXISTS_REPLACE);

  // Defaults to files directory
  // Process default user image through ImageCache
  $preset = imagecache_preset_by_name('profile_pictures');
  imagecache_build_derivative($preset['actions'], $user_image, file_directory_path() . '/imagecache/profile_pictures/default-user.png');

  // Process default user image thumbnail through ImageCache
  $preset = imagecache_preset_by_name('user_picture_meta');
  imagecache_build_derivative($preset['actions'], $user_image, file_directory_path() . '/imagecache/user_picture_meta/default-user.png');

  // Set user image as the default
  variable_set('user_picture_default', 'default-user.png');

  // Process default group image through ImageCache
  $preset = imagecache_preset_by_name('group_images');
  imagecache_build_derivative($preset['actions'], $group_image, file_directory_path() . '/imagecache/group_images/imagefield_default_images/default-group.png');

  // Process default group image thumbnail through ImageCache
  $preset = imagecache_preset_by_name('group_images_thumb');
  imagecache_build_derivative($preset['actions'], $group_image, file_directory_path() . '/imagecache/group_images_thumb/imagefield_default_images/default-group.png');

  // Simulate that we've uploaded the group image
  $file = new stdClass();
  $file->uid = 1;
  $file->filename = 'default-group.png';
  $file->filepath = file_directory_path() . '/' . $file->filename;
  $file->filemime = 'image/png';
  $file->filesize = filesize($group_image);
  $file->status = 1;
  $file->timestamp = time();
  drupal_write_record('files', $file);
}