You are here

function focal_point_create_test_image in Focal Point 7

Create a test drive image.

If the test drive image already exists as a managed file, it will be replaced by this update.

Parameters

string $scheme: The file scheme for saving a test image.

1 call to focal_point_create_test_image()
focal_point_update_7005 in ./focal_point.install
Update test drive image to use file default scheme, so remote schemes work.

File

./focal_point.install, line 114
Install hooks for focal_point.

Code

function focal_point_create_test_image($scheme) {
  variable_del('focal_point_test_drive_focal_point');

  // Create an image to use for the "Test Drive" page.
  $test_drive_image = array(
    'scheme' => $scheme . '://',
    'dest_directory' => 'focal_point',
    'source_path' => drupal_get_path('module', 'focal_point') . '/images/' . 'test-drive.jpg',
    'file_name' => 'test-drive.jpg',
  );
  $full_dir = $test_drive_image['scheme'] . $test_drive_image['dest_directory'];
  $file_uri = $full_dir . '/' . $test_drive_image['file_name'];
  file_prepare_directory($full_dir, FILE_CREATE_DIRECTORY);
  file_unmanaged_copy($test_drive_image['source_path'], $file_uri, FILE_EXISTS_REPLACE);
  $file = (object) array(
    'uid' => 1,
    'status' => FILE_STATUS_PERMANENT,
    'filename' => $test_drive_image['file_name'],
    'uri' => $file_uri,
    'filemime' => file_get_mimetype($test_drive_image['source_path']),
  );
  $file = file_save($file);
  if ($file) {
    variable_set('focal_point_test_drive_image', $file->fid);
  }
}