--- upload_preview.module.original 2007-06-17 16:04:29.000000000 +0200 +++ upload_preview.module 2007-07-30 12:39:42.000000000 +0200 @@ -100,19 +100,28 @@ function _upload_preview_node_form(&$fil * Implementation of hook_upload_preview(). */ function upload_preview_upload_preview($file) { + + // Change the filepath if the file is handled by the image module. + $img_path = variable_get('image_default_path', 'images') . "/"; + if ( substr($file->filepath, 0 , strlen($img_path) ) == $img_path ) { + $filepath = file_directory_path() . "/" . $file->filepath; + } else { + $filepath = $file->filepath; + } + // Only check for images if (strpos($file->filemime, 'image/') === 0) { // Create the preview image file path based on the actual filename or the // preliminary filename (in the temp directory). $path = file_create_path(variable_get('upload_preview_path', 'preview')) .'/'; - $path .= md5($file->filepath) .'.'. _upload_preview_mime_to_extension($file->filemime); + $path .= md5($filepath) .'.'. _upload_preview_mime_to_extension($file->filemime); // If the file does not exist, try to scale it down if (!file_exists($path)) { $size = explode('x', variable_get('upload_preview_size', '150x150')); - if (!image_scale($file->filepath, $path, $size[0], $size[1])) { + if (!image_scale($filepath, $path, $size[0], $size[1])) { // Scaling failed, now try copying the original file over. - if (!file_copy($file->filepath, $path, FILE_EXISTS_ERROR)) { + if (!file_copy($filepath, $path, FILE_EXISTS_ERROR)) { // If every attempt failed, don't show a preview. $path = NULL; }