function uc_option_image_install in Ubercart Option Images 6
Implements hook_install(). Adds default option image to file system.
File
- ./
uc_option_image.install, line 12 - Provides install and uninstall hooks.
Code
function uc_option_image_install() {
$default_image_path = drupal_get_path('module', 'uc_option_image') . '/no_image.png';
$default_image_name = 'option_image_0_0_0';
$file_path = db_result(db_query("SELECT fid from {files} WHERE filename = '%s' AND filepath = '%s'", $default_image_name, $default_image_path));
// Make sure image doesn't already exist in the files table.
if (!$file_path) {
$info = image_get_info($default_image_path);
$file = (object) array(
'uid' => 1,
'filename' => $default_image_name,
'filepath' => $default_image_path,
'filemime' => $info['file_mime'],
'filesize' => $info['file_size'],
'status' => FILE_STATUS_PERMANENT,
);
drupal_write_record('files', $file);
}
}